Marcus
Marcus

Reputation: 9472

How to Debug ajax REST calls (in general)

I have an cURL call that works and I have converted it to an ajax call. The ajax call is failing. How do I get something to return from the call? There should be a dictionary [cURL call returns a dictionary].

How do I know what is failing in my call? I don't know how to proceed in debugging it.

Thanks

curl -v -X PUT -H "Content-Type: application/json" -H "Accept: application/json" -X PUT --user user:pass https://my.address.for/this/url -d "{\"name\": \"Marcus0.3\",\"start\": 500000,\"end\": 1361640526000}"


                    $.ajax({
                    type: 'put',
                    url: 'https://my.address.for/this/url',
                    dataType: 'json',
                    async: false,
                    username: 'user',
                    password: 'pass',
                    data: {
                        "name": "Marcus0.3",
                        "start": 500000,
                        "end": 1361640526000
                    },
                    success: function(){alert('DONE!');},
                    error: function(){alert('fail');},
            }).responseText;

I keep getting 'fail' responses

Upvotes: 1

Views: 797

Answers (2)

Jonah
Jonah

Reputation: 16202

If you type F12 it will open up chrome dev tools, then click on the network tab.

You will see all requests, including ajax requests as they happen. You can click on the line item "name" field for full info about the request and response, similar to cURL verbose mode

Upvotes: 1

Durai
Durai

Reputation: 582

You can use Firefox with firebug to get the exact error message.Else do like this

error:function(error){alert(error)}

Upvotes: 0

Related Questions