I am new to jquery and would like to understand what is the difference between response and response.d, i am using response.d in failure alerts.
i wanted to know in case of failure what alert(respose.d) would display in message box.
below is my code
$.ajax({
type: "POST",
url:"Abc.aspx/Function1",
data: '{MonthDateID: ' + $('#<%=ddlMonth.ClientID%>').val() + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: Function2,
failure: function(response) {
alert(response.d);}});
Please do let me know in case of any query
d. If you put only response in alert it will show you something like [Object] in the alert. Suppose, response contains a message "Ajax call made successfully" then to see the message you have to use response. d ("d") property of response. Follow this answer to receive notifications.
data is the JSON object returned from the endpoint. d is one of the properties of it, you are checking if the d property of data is equal to the string 'success'.
Its is very clear that $("#div").html(result.d); in your code. "result" is a object and d is property of "result".
response is the object always. In order to to get your data you have to use response.d.
If you put only response in alert it will show you something like [Object]
in the alert.
Suppose, response contains a message "Ajax call made successfully" then to see the message you have to use response.d ("d") property of response.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With