0

I have searched lot of on this issue and tried almost everything but it doesn't seem to be work so posting it here.

I am trying to make jquery ajax call to ashx handler by passing json data. But my request doesnt reach till handler GetBalance.ashx

code :

 var mydata = {};

$.ajax({
    url: 'Handlers/GetBalance.ashx?type=authenticateRequest',
    type: 'post',
    dataType: 'json',
    cache: false,
    data: mydata,
    success: function (data) {
    },
    error: function (xhr, status) {
        console.log(status);
        console.log(xhr.responseText);
    }
});

in console it prints

parsererror
(empty string)

What i am doing wrong ? It should reach till .ashx before it gives any response parse error

Edit:

Changed as suggested by answer

Shaggy
  • 5,422
  • 28
  • 98
  • 163
  • here you find the answer – john Smith Aug 08 '14 at 10:51
  • http://stackoverflow.com/questions/14468704/what-changed-in-jquery-1-9-to-cause-a-ajax-call-to-fail-with-syntax-error – john Smith Aug 08 '14 at 10:52
  • could u post your ashx handler as well – sakir Aug 08 '14 at 11:50
  • Look in the Net tab of your developer tools. Do you see the HTTP request you expect? Do you see the HTTP response you expect? – Quentin Aug 08 '14 at 12:47
  • The output you describe on the console looks like the results of the `error` function, as far as I know that won't run unless the request has hit your `.ashx` and get a response (with an error message in it). – Quentin Aug 08 '14 at 12:48

1 Answers1

0

Replace your line

data: mydata,

with

data: JSON.stringify(mydata),
contentType: "application/json",
Ronak Patel
  • 2,570
  • 17
  • 20