Quantcast
Channel: Question and Answer » json
Viewing all articles
Browse latest Browse all 148

Javascript calls C# code and parser error

$
0
0

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:

image 1

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.


Viewing all articles
Browse latest Browse all 148

Trending Articles