Wednesday 10 October 2012

Handling json data on ajax

Hi all,

Whenever you send json data on ajax you should use encodeURIComponent() method to encode json data other wise special chars in json data like '&,?' may disturbs the url data posting to the server.
i.e
$.ajax({

url: 'ajax/test-page.php',
data: 'usr_data='+encodeURIComponent(frmdata)

}); 

No comments:

Post a Comment