I'm getting the result, "undefined", from my AJAX call in the success block.
- AJAX calls a web method in my cs file, while passing a vale (a date).
- My web method build s a calendar from the date and passes all of the HTML code back.
- The success function does not pick up the data passed from the web method.
I have used the exact same code on a few other web apps, and it works great, just not on this one. The difference is, I'm not using a blank .net web forms build, but a template with bootstrap. I have verified that the web method is correctly building the calendar text/HTML, it's just not getting read by the result.d in the AJAX success. I have looked through other posts of users having the same issue, but none of the solutions worked for me.
$.ajax({
type: "POST",
url: "Calendar.aspx/getCal",
data: "{'dateParam': '" + newDate + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (retValue)
{
var myReturn = retValue.d;
document.getElementById("divPh").innerHTML = myReturn;
} ,
error: function (data) {
alert('error: ' + data.status);
}
});
//Web Method on Calendar.aspx.cs page. Pulled out complicated code to simply
//show a hard-coded return.
[WebMethod]
[ScriptMethod(UseHttpGet = false)]
public static string getCal(string dateParam)
{
string retValue = "This Sucks";
return retValue;
}