I want to send Json to a web service on the same server. But I do not know how to host Json using jQuery. I tried with this code:
$.ajax({ type: 'POST', url: '/form/', data: {"name":"jonas"}, success: function(data) { alert('data: ' + data); }, contentType: "application/json", dataType: 'json' });
But using this jQuery code, data is not accepted as Json on the server. This is the expected data on the server: {"name":"jonas"} , but using jQuery the server gets name=jonas . Or, in other words, this is "urlencoded" data, not Json.
Is there a way to publish data in Json format instead of urlencoded data using jQuery? Or do I need to use ajax manual request?
Jonas Jun 06 '11 at 16:50 2011-06-06 16:50
source share