A lot of things won't happen. I started from scratch. Here I use pagemethods to call the background method.
Write two methods in the background, one with parameters and the other without parameters.
[System. Web. Services. webmethod]
[System. Web. Script. Services. scriptmethod]
PubliCStaTiC objecT getstatus ()
{
Return System. datetime. Now. tostring ();
}
[System. Web. Services. webmethod]
[System. Web. Script. Services. scriptmethod]
PubliC static objecT setname (string firstname, string lastname)
{
Return firstname + "" + lastname;
}
Call in script
<Script language = "JavaScript" type = "text/JavaScript">
/*
Note:
(A) The server-side method to be called must be marked with the system. Web. Services. webmethod feature.
(B) The server-side method to be called must be a public static method.
(C) The server method to be called should be written on the. ASPX page (or the corresponding backgroundCodeFile), should not be written in the User Control
*/
Window. setinterval (function (){
Pagemethods. getstatus (function (result ){
If (result ){
Alert (result); // The current time
}
});
},3000 );
window. onload = function () {
pagemethods. setname ("Zhang", "Jinshan", function (result) {
alert (result); // name
});
}
// The following statements are incorrect:
Pagemethods. setname ("Zhang", "Jinshan", function (result ){
Alert (result );//Pop-up name
});
</SCRIPT>
In the form, you need to addEnablepagemethods = "true"
enablepagemethods =" true "