Is there a way in Ajax to not send variables in the url BUT using hidden variables?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zanzo
    New Member
    • Mar 2008
    • 16

    #1

    Is there a way in Ajax to not send variables in the url BUT using hidden variables?

    usually we create a url with parameters and values and send it via ajax to not loading page.

    Is there a way to not send variables in the url BUT using hidden variables??

    I have a problem in my website that doesn't permit me to send variable in url, so the ajax is not working anymore:

    the problem is when i choose a language and the url become like this:
    http//..../en/page -->here it is impossible to add variables to the url and success

    is there a way to solve this issue??

    hope i do get help

    Best regards,
    zanzo
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    yes ... just use a POST request ... i think this is what you want ;) ... you may have a look here for a start ...

    kind regards

    Comment

    • zanzo
      New Member
      • Mar 2008
      • 16

      #3
      actually I changed the ajax call to post, but I still can see the parameters in the URL!!!!

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        without having a look at what you have done it is hard to tell anything about this problem ;) ... please show the relevant parts of the code where you 'load up' the request ...

        kind regards

        Comment

        • zanzo
          New Member
          • Mar 2008
          • 16

          #5
          Code:
          bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
          page_request.open('POST', url, true)
          page_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          page_request.setRequestHeader("Content-length", bustcacheparameter.length);
          page_request.setRequestHeader("Connection", "close");
          
          page_request.send(bustcacheparameter)
          Last edited by gits; Oct 30 '08, 10:09 AM. Reason: added code tags

          Comment

          • zanzo
            New Member
            • Mar 2008
            • 16

            #6
            Code:
            page_request.onreadystatechange=function(){
            loadpage(page_request, containerid)
            }
            
            
            
            function loadpage(page_request, containerid){
            if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
            document.getElementById(containerid).innerHTML=page_request.responseText
            }
            Last edited by gits; Oct 30 '08, 10:09 AM. Reason: added code tags

            Comment

            • zanzo
              New Member
              • Mar 2008
              • 16

              #7
              now it is working but not in the all pages :s

              I'm using AJAX for paging, and i have 2 paging in the page (on in the top and other in the footer), the footer paging is working, the other no!!

              what could be the problem with that

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5390

                #8
                glad to hear that it works a bit ;) ... but now again ... i need more info regarding this new problem: how many requests are started at once? do you use a global request-reference? may be you start a request and just abort a running one with reusing the reference for a new one? this is most likely the problem - you could test it with seperating the requests, just avoid the footer-request and see whether the code works ... if it works you just need to use different references (variables) instead of only one global for your requests.

                kind regards

                PS: and please use the CODE tags when posting source-code

                Comment

                • zanzo
                  New Member
                  • Mar 2008
                  • 16

                  #9
                  Well everything now is working :D thanks a lot for your help gits ;)

                  ok next time I will use the CODE tags when posting source-code ;)

                  Comment

                  • gits
                    Recognized Expert Moderator Expert
                    • May 2007
                    • 5390

                    #10
                    no problem, you are welcome ... could you just drop a short note about the solution? what was the problem and how did you solve it ... so that other users with similar problems that might read this thread in the future might see what the problem/solution was?

                    kind regards

                    Comment

                    • zanzo
                      New Member
                      • Mar 2008
                      • 16

                      #11
                      ok have no problem,

                      first as i was using the Get method when requesting variables i used $_GET, while now it should be $_POST, also I should send some parameters in the url like "id" depending on the page, before using the post method i didn't have this prob.

                      Comment

                      • gits
                        Recognized Expert Moderator Expert
                        • May 2007
                        • 5390

                        #12
                        thanks for taking time to share your solution ... hopefully this might help users with similar problems in the future ;)

                        kind regards

                        Comment

                        Working...