afridy
October 13, 2011, 9:31pm
1
Hai folks,
my html form ‘company description’ field sends “Computer Repair & Maintenance” value to php via ajax get method.
$description = $_POST["description"];
all i am getting is ‘Computer Repair’ part only. ‘& Maintenance’ is missing.
how to solve this issue?
i just tried putting
$description =urlencode( $_POST["description"]);
nop, not working…
pls help
rpkamp
October 13, 2011, 9:47pm
2
you need to use encodeURIComponent in the AJAX script. When you’re in the PHP you’re too late, the damage is already done, because it will send your request like [noparse]http://somedomain.com/?somekey=Computer Repair & Maintenance[/noparse], so PHP will get array(‘somekey’ => 'Computer Rapair ‘, ’ Maintenance’ => ‘’);
afridy
October 13, 2011, 10:05pm
3
rpkamp:
you need to use encodeURIComponent in the AJAX script. When you’re in the PHP you’re too late, the damage is already done, because it will send your request like [noparse]http://somedomain.com/?somekey=Computer Repair & Maintenance[/noparse], so PHP will get array(‘somekey’ => 'Computer Rapair ‘, ’ Maintenance’ => ‘’);
Thank you !! ill try what you suggessted.
afridy
October 14, 2011, 7:10am
4
rpkamp:
you need to use encodeURIComponent in the AJAX script. When you’re in the PHP you’re too late, the damage is already done, because it will send your request like [noparse]http://somedomain.com/?somekey=Computer Repair & Maintenance[/noparse], so PHP will get array(‘somekey’ => 'Computer Rapair ‘, ’ Maintenance’ => ‘’);
Works charm !!!
Thank you Scallio
var params = "name=" + encodeURIComponent(name) ;
var params = params + "&description=" + encodeURIComponent(description) ;
var params = params + "&address=" + encodeURIComponent(address) ;