I read alot about this on this forum, but I cant make it work.
I want to use the ajax function on my asp.net web application
So here is the Javascript on VerifMain.aspx
$(document).ready(function () {
//menu()
$("#btnImprimer").click(function () {
$.ajax({
type: "POST",
url: "/VerifMain.aspx/Lol",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert("Good");
},
error: function (msg) {
alert(msg);
}
});
});
});
And here is the server code in VerifMain.aspx.vb
Partial Public Class _Default
Inherits Page
<WebMethod()> _
Public Shared Sub Lol()
//TO DO
End Sub
End Class
So when I'm trying to call this method, It goes in the error function and the alert is "[object Object]"
I have to use JQuery because where I work the Microsoft Ajax is not installed.
I really need help for this, I don't understand what I do wrong and I'm stuck with ie7 only and almost every websites are blocked.
Thank you!
Have a nice day!!
EDIT: Hi everyone Thank you for your time!
I fixed it by removing the the partial class.
so now it's only a static web method in the server code and it works.
<WebMethod()> _
Public Shared Sub Lol()
//TO DO
End Sub
To be honest, I don't understand how it works
but thank you for your fast replies.
This is the best website, I will spend some free time here now ;)