Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-12-2009, 01:51 AM   PM User | #1
Bmiller
New to the CF scene

 
Join Date: Feb 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Bmiller is an unknown quantity at this point
Cool Help passing a URL as param via POST

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:
Code:
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?
Bmiller is offline   Reply With Quote
Old 02-12-2009, 03:23 AM   PM User | #2
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Quote:
Originally Posted by Bmiller View Post
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:
Code:
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:
Code:
params = 'url=' + escape(url) + '&myotherdata=' + escape(data);
name must be explicit and usualy is better to escape value.

best regards
oesxyl is offline   Reply With Quote
Users who have thanked oesxyl for this post:
Bmiller (02-12-2009)
Old 02-12-2009, 05:01 AM   PM User | #3
Bmiller
New to the CF scene

 
Join Date: Feb 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Bmiller is an unknown quantity at this point
Thanks, that did it! I think my brain was just a bit overloaded from a little too much work.
Bmiller is offline   Reply With Quote
Old 02-12-2009, 05:09 AM   PM User | #4
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Quote:
Originally Posted by Bmiller View Post
Thanks, that did it!
you are welcome,

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

best regards
oesxyl is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:01 PM.


Advertisement
Log in to turn off these ads.