I have a simple AJAX call: $.ajax({ url: "setBMBJSONString.php", data: stringJSON.toString(), <---------------------------------------------------- success: function(rdata) { //var resp = eval('(' + rdata + ')'); $("body").append(rdata); }, error: function(XMLHttpRequest, textStatus, errorThrown) { var e = XMLHttpRequest; for (var key in e) { $("body").append(key + ": " + e[key] + "<br />"); } } });
That won't work, the data doesn't get to the webservice that way. But if I do this instead: $.ajax({ url: "setBMBJSONString.php", data: {"prefix":"Bishop","fname":"Nkulu","mname":"Ntanda","lname":"Ntambo","suffix":"Esq.","relation":""}, success: function(rdata) { //var resp = eval('(' + rdata + ')'); $("body").append(rdata); }, error: function(XMLHttpRequest, textStatus, errorThrown) { var e = XMLHttpRequest; for (var key in e) { $("body").append(key + ": " + e[key] + "<br />"); } } }); Everything works fine! All I did was print out stringJSON and copy it and paste it in there. What's going on? For obvious reasons I need to use a variable there.