Differences between Ajax and callback
The content on this page is: the difference between Ajax and callback.ArticleThis site is reposted from the network. If any infringement occurs, we will delete it in time. The body of the content is as follows:
AJAX can call back the server method on the client, or callback. The difference between Ajax and callback lies in the following two points:
I. Callback can only return the string type, while AJAX can return other types, such as dataset, or the type you define.
II. Ajax logic is simpler than callbcak,
Callback is divided into the following steps:
1) register the client script on the server
String callbackref = page. clientscript. getcallbackeventreference (this, "Param", "handleresultfromserver", "context ");
// Handleresultfromserver is the function name of the client function returned by the server after processing.
String callbackscript = "function calltheserver (Param, context)" + "{" + callbackref + "};";
Page. clientscript. registerclientscriptblock (this. GetType (), "calltheserver", callbackscript, true );
2) The client calls the calltheserver function to pass parameters to the server.
3) receive and process parameters on the server
4) The server returns the string type parameter to the client.
5) The client receives and processes parameters.
Ajax is divided into the following steps:
1) register the client script on the server
Ajax. Utility. registertypeforajax (typeof (pageclass); // pageclass is the class name of the page.
Alternatively, you can manually add the script on the client:
2) The client directly calls the server method (but there is one more parameter than the method, is the function name of the client function that the server returns the parameter to after processing)
3) The server method returns the object to the client
4) the client receives and processes
Ajax is more convenient, especially when several callbacks need to be processed on a page.