Asp.net: PageMethods call results in error "Type 'System.String' is not supported for deserialization of an array."

242 Views Asked by At

I'm try to use PageMethods to call a code behind static method, but it looks like it never gets to that method. It just fails with the error

"Type 'System.String' is not supported for deserialization of an array."

I have this working on another part of my program so I'm confused why it's broke here. I'm using a third party plugin jQuery called Chosen I wonder if that is the issue? Here is my code:

JavaScript file

$('.txtBusinessUnit').chosen().change(function ()
{
    var bu = $('.txtBusinessUnit').val();
    PageMethods.BUChanged(bu, onBUSuccess, onBUFailure); 
});

function onBUSuccess(result) {
alert(result)
}

function onBUFailure(error) {
    alert(error); //errors message listed above
} 

code behind

[WebMethod]
public static string BUChanged(string BU)
{
  return "it works";
}

Update: I used the Chrome debugger. It has the following error:

POST http://localhost:54234/Default.aspx/BUChanged 500 (Internal Server Error)

it errors on ScriptResource.axd with send(body) at this line

this._xmlHttpRequest.send(body);

With the following error

Failed to load resource: the server responded with a status of 500 (Internal Service Error)

Not sure what this means really..

0

There are 0 best solutions below