Reputation: 1
I am using webrtc(javascript,json,ajax) client to send request and c#web service to validate on server. I am posting a json request and the result is being displayed as xml in the console of the browser. Is there a way to get the response as an alert or pop up message using javvascript?
jQuery.ajax({
url: urlPath,
type: "POST",
contentType: "application/jsonp; charset=utf-8",
data: jsond,
dataType: "jsonp",
success: function (response) {
alert("Details saved successfully!!!" + response);
alert(xhr.responseText);
},
Upvotes: 0
Views: 587
Reputation: 2798
According to http://api.jquery.com/jQuery.ajax/ the success: of ajax call is being passed three parameters 1. Data(plainObject) 2. TextStatus(string) 3. jqXHR object(typeof jqXHR)
To extract the serverResponse, write this in the "success" Callback
success: function (data,TextStatus, xhr) {
alert(xhr.responseText);
},
Or if you want to display the data(as returned from the server), then you need to parse your data like this.
success: function (data,TextStatus, xhr) {
var newData = JSON.parse(data)
alert(newData);
}
Upvotes: 1