By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,793 Members | 1,252 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,793 IT Pros & Developers. It's quick & easy.

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

P: 16
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
Oct 30 '08 #1
Share this Question
Share on Google+
11 Replies


gits
Expert Mod 5K+
P: 5,328
yes ... just use a POST request ... i think this is what you want ;) ... you may have a look here for a start ...

kind regards
Oct 30 '08 #2

P: 16
actually I changed the ajax call to post, but I still can see the parameters in the URL!!!!
Oct 30 '08 #3

gits
Expert Mod 5K+
P: 5,328
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
Oct 30 '08 #4

P: 16
Expand|Select|Wrap|Line Numbers
  1. bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
  2. page_request.open('POST', url, true)
  3. page_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  4. page_request.setRequestHeader("Content-length", bustcacheparameter.length);
  5. page_request.setRequestHeader("Connection", "close");
  6.  
  7. page_request.send(bustcacheparameter)
Oct 30 '08 #5

P: 16
Expand|Select|Wrap|Line Numbers
  1. page_request.onreadystatechange=function(){
  2. loadpage(page_request, containerid)
  3. }
  4.  
  5.  
  6.  
  7. function loadpage(page_request, containerid){
  8. if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
  9. document.getElementById(containerid).innerHTML=page_request.responseText
  10. }
Oct 30 '08 #6

P: 16
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
Oct 30 '08 #7

gits
Expert Mod 5K+
P: 5,328
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
Oct 30 '08 #8

P: 16
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 ;)
Oct 30 '08 #9

gits
Expert Mod 5K+
P: 5,328
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
Oct 30 '08 #10

P: 16
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.
Oct 30 '08 #11

gits
Expert Mod 5K+
P: 5,328
thanks for taking time to share your solution ... hopefully this might help users with similar problems in the future ;)

kind regards
Oct 30 '08 #12

Post your reply

Sign in to post your reply or Sign up for a free account.