...

View Full Version : Help passing a URL as param via POST



Bmiller
02-12-2009, 02:51 AM
Hello, I'm new to using Ajax but pretty good with Javascript, but am stuck on something I writing and need some help.

I am passing a XMLHttp request via post and passing some parameters to it. The code is working fine and dandy, and I am using a name/value pair string to pass the parameters as such:



params = "name="+ value+ '&r=' + Math.random();



My problem is this: one of the values I am passing is a URL, which may contain its own query string attached to it. (Imagine a bookmarking type script) If I pass it along as url=url&myotherdata=data... the name/value pairs of the get mixed up when I'm reading it later on my php script.

Any suggestions?

oesxyl
02-12-2009, 04:23 AM
Hello, I'm new to using Ajax but pretty good with Javascript, but am stuck on something I writing and need some help.

I am passing a XMLHttp request via post and passing some parameters to it. The code is working fine and dandy, and I am using a name/value pair string to pass the parameters as such:



params = "name="+ value+ '&r=' + Math.random();



My problem is this: one of the values I am passing is a URL, which may contain its own query string attached to it. (Imagine a bookmarking type script) If I pass it along as url=url&myotherdata=data... the name/value pairs of the get mixed up when I'm reading it later on my php script.

Any suggestions?
I'm not sure I understand the problem but for your example params must look like this:


params = 'url=' + escape(url) + '&myotherdata=' + escape(data);


name must be explicit and usualy is better to escape value.

best regards

Bmiller
02-12-2009, 06:01 AM
Thanks, that did it! I think my brain was just a bit overloaded from a little too much work. :)

oesxyl
02-12-2009, 06:09 AM
Thanks, that did it!
you are welcome, :)


I think my brain was just a bit overloaded from a little too much work. :)
no problem, it's happend, :)

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum