I am making jquery ajax call to post data on server and return response from whether completed successfully or not. But I am not able to see response in js.
js:
$.ajax({
url: 'ajaxExecute.aspx/CAO2',
data: strRequest,
dataType: "json",
contentType: "application/json",
cache: false,
context: document.body,
type: 'POST',
success: function (response) {
alert(response);
window.parent.$('#divDialog').dialog('close');
window.parent.$('#divDialog').dialog('destroy');
window.parent.$('#divDialog').html(response);
window.parent.$('#divDialog').attr('title', 'Error');
window.parent.$('#divDialog').dialog({ show: "blind", modal: true, dialogClass: 'alert', zIndex: 99999, resizable: false, draggable: false });
}
});
here i am not getting any alert but able to see response in Chrome -> Inspect Element -> Network -> Response
cs
[WebMethod]
public static void CAO2(string Guardian, string CIFID, string EmploymentType)
{
try
{
if (Guardian != "" && CIFID != "" && EmploymentType != "" )
{
if (Generix.putCustomerDetailsPart2(Guardian,CIFID,EmploymentType)) // Will Create SQL Query And Execute on Database
{
HttpContext.Current.Response.Write("Information Submitted Successfuly..!!<br/><br/>Please Visit Your Nearest Branch...");
}
else
{
HttpContext.Current.Response.Write("Error Occurred While Processing Information..!!<br/><br/>Please Try Again...");
}
}
else
{
HttpContext.Current.Response.Write("Missing Information..!!");
}
}
catch (Exception xObj)
{
HttpContext.Current.Response.Write("ERROR: " + xObj.Message);
}
}
where I am missing?
alert(d.response)?alert(d.response)actually.response.d&d.responsebut didnt workdataTypetojson, but write plain text in response. SetdataTypetotext.