What I used to do with WebMethods being called from jQuery in VS2010 no longer works with VS2013. Here is the page service code:
Imports System.Web.Services
Imports System.Web.Script.Services
Imports System.Web.Script.Serialization
<WebMethod()> _
Public Shared Function Test() As String
Dim strTest As String = "Testing"
Return strTest
End Function
Here is the jQuery to call the method:
function TestService() {
$.ajax({
type: "POST",
url: "myPage.aspx/Test",
contentType: "application/json; charset=utf-8",
data: '[]'
})
.done(function (d) {
alert('success');
})
.fail(function (xhr, st, err) {
alert('failed');
});
}
And as you can guess I am getting the failed alert always. This works perfectly in 2010. Can't find any thing new in the docs.
The parameter data: '[]'
isn't a string but an object. You have to change it to :
data: { myproperty: 'value' }
or simply remove the data parameter.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.