Gopal Biswas Gopal Biswas - 2 months ago 10
Ajax Question

How to get the data value during Jquery Ajax calling?

I'm calling Ajax like below

$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",

url: path,
dataType: "json",

data: '{ "jsondata":' + jsondata + ',"key":"' + getValue('id') + '"}',
success: function (data) {
callback(data);
},
error: function (error) {
callback(error.responseText);

}
});


I want to get the "Data" value at calling time because after the call the execution doesn't goes to the desired web method and the error is showing like
""Message":"Invalid web service call, missing value for parameter: \u0027obj\u0027..."

I have to track the the Ajax posting value during Ajax call and find out what is the problem with posting data.Is there any tricks to get the data value before Ajax calling?
Any help will be appreciated.

Edit: I'm sending the jsondata value like below

var jsondata = '{ "pagenumber":"' + pagenumber + '","sortColumn":"' + sortColumn + '","sortDirection":"' + sortDirection + '","rowPerPage":"' + rowPerPage + '"}';


Thanks.

Answer

I was just checking with below code - please have a look. please check beforesend content

   $.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",

    url: '/dummy',
    dataType: "json",

    data: '{dummy:"dummy"}',
    success: function (data) {
       alert(data);
    },
    error: function (error) {
       alert(error);

    },
      beforeSend: function(data,data1) {

    console.log('before'+data1.data)
 },
});
 })
});
Comments