I am trying to get my javascript to call some C# code that I have added to my Sharepoint site. Unfortunately every time it runs, I’m not getting the “Success” i had programmed in. Instead I get this:
My Javascript code:
function test() {
$.ajax({
type: "POST",
url: 'NewForm.aspx/doThis',
data: "",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert("Success");
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("Request: " + XMLHttpRequest.toString() + "nnStatus: " + textStatus + "nnError: " + errorThrown);
}
});
};
And My C# code:
[WebMethod]
public static void doThis()
{
//Code
}
The code is not supposed to do anything yet, but print out success if it was able to get to the method.