I am trying to make a ajax request using jquery:
$.ajax({
url: "/src/ax_query_places",
dataType: "json",
data: {
query: value
},
success: function(response) {
alert("Success");
},
failure: function() {
alert('Could not get airports');
},
error: function() {
alert('Error');
}
});
I am encoding the json on server side. The json data received on response is :
{
"places": [
{
"name": "New\x20Orleans,\x20US\x20\x28New\x20Lakefront\x20\x2D\x20NEW\x29",
"code": "NEW"
},
{
"name": "New\x20Bedford,\x20US\x20\x28All\x20Airports\x20\x2D\x20EWB\x29",
"code": "EWB"
}
]
}
But I am receiving error every time. Please suggest if there is a mistake in syntax. Or how should I parse the encoded response?
Also if I remove the encoding of json on the server side, everything works fine.
failureproperty, so you can remove that, it will never be fired.