Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

response.d in jquery

Tags:

jquery

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

like image 719
user1717270 Avatar asked Nov 19 '12 07:11

user1717270


People also ask

What is response d Ajax?

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.

What is data D in Ajax?

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'.

What is D in JSON?

Its is very clear that $("#div").html(result.d); in your code. "result" is a object and d is property of "result".


1 Answers

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.

like image 148
Narendra Avatar answered Oct 02 '22 04:10

Narendra