Reputation: 45
I have the below jquery which fetches a JSON object returned by a web service, but I get a parsererror most of the times.
$.ajax({
type: "GET",
url: 'scripts/php/fetchProbableDrivers.php',
dataType: 'json',
data: {'tripId' : tripId },
error: function(e)
{
alert(JSON.stringify(e, null, 4));
},
success: function(drivers){
}
Can someone please help me with this?
Upvotes: 0
Views: 8259
Reputation: 658
I think that there is a formatting issue with your json format .
You can check your response by changing data type to "html" and put the alert in success.. some thing like this.
$.ajax({
type: "GET",
url: 'scripts/php/fetchProbableDrivers.php',
dataType: 'html',
data: {'tripId' : tripId },
error: function(e)
{
alert(JSON.stringify(e, null, 4));
},
success: function(strDrivers){
alert( strDrivers );
}
Then copy you response and validate your response from the site http://jsonformatter.curiousconcept.com/
I hope that using that way you can easily figure out the formatting issue .
Upvotes: 1
Reputation: 4701
Check the JSON object which is returned by fetchProbableDrivers.php
There might be formatting issue with the JSON returned.
Verify the formatting of the returned JSON using http://jsonformatter.curiousconcept.com/
Upvotes: 0