I am taking user input sending it to server using jQuery ajax...after inserting user values in database I am sending response back to client as JSON string as following
echo '{"success":"true","data":"'.nl2br($a).'","type":"text"}';
as user input can contain new line, I am using nl2br so that all new line characters are converted to <br> and also know that JSON doesnt support multi line, thats why I am using nl2br....but parsing is failing at client side
pls tell me what the reason and how can I solve it?
parsing code var obj = jQuery.parseJSON(data);
dadad","type":"text"}` this my response at client side – vikas devde Apr 01 '13 at 19:20
dadad","type":"text"}')` works fine, wich suggests that the JSON your client recieves is not what you pasted. Are you sure the code gets executed at all? – plalx Apr 01 '13 at 19:33