•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 375,198 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,986 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 698 | Replies: 3 | Solved
![]() |
•
•
Join Date: Mar 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Hi All,
I am trying to send some data using Ajax and recieve that data in php code using _POST method.
But my data contains "&" and _POST method takes it as a seperating token and data after tht does not get passed. Does anyone has a solution to this.
Code snippet:
And on server side when I use
it takes & as a seperator which is present as data.
Please someone let me know the workaround or approach to this.
I am trying to send some data using Ajax and recieve that data in php code using _POST method.
But my data contains "&" and _POST method takes it as a seperating token and data after tht does not get passed. Does anyone has a solution to this.
Code snippet:
params = "q="+str+"&p="+str1; //here str1 contains data which has &
xmlHttp.open("POST",url,false);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.send(params); And on server side when I use
$posted = &$_POST ;it takes & as a seperator which is present as data.
Please someone let me know the workaround or approach to this.
Last edited by peter_budo : Mar 24th, 2008 at 6:20 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Nov 2007
Location: Las Vegas, Nevada
Posts: 83
Reputation:
Rep Power: 1
Solved Threads: 14
Last edited by johnsquibb : Mar 24th, 2008 at 10:33 am. Reason: typo
The End
•
•
Join Date: Mar 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Thanks John for the input. This what I have done. If one wants to encode and decode the URL in javascript then above reference is fine. In my case i needed to encode at javascript and and decode inside php. The function to be used inside php code is
preg_replace('/%([0-9a-f]{2})/ie', 'chr(hexdec($1))', (string) $p); $p is the string which has encoded value. And the first 2 parameters just does enough to decode back whatever [CODE ] encodeURIComponent [/code] has done.
Thanks
Last edited by rajivloharuka : Mar 25th, 2008 at 1:38 am.
•
•
Join Date: Nov 2007
Posts: 86
Reputation:
Rep Power: 1
Solved Threads: 6
just out of curiosity, would str_replace not have worked easier for this?
You have a string (as a variable at least) and you know what other string is inside of it (or could be inside of it), and you know what you want to replace it with.
http://us.php.net/manual/en/function.str-replace.php
Sage
You have a string (as a variable at least) and you know what other string is inside of it (or could be inside of it), and you know what you want to replace it with.
http://us.php.net/manual/en/function.str-replace.php
Sage
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
access advice ajax asp business classification code combo cult of the dead cow daniweb data data protection database developer development dropdownlist encryption europe forensic forensics fun google hacking hardware help home industrial espionage information internet it microsoft module msdn net news office payment services privacy reuse security site software sql storage terabyte tutorials and more tv vista web wikipedia
- Previous Thread: How to arrange a Profile.
- Next Thread: send e-mail every new entry on table on db


Linear Mode