tailieunhanh - Beginning Ajax with ASP.NET- P14

Beginning Ajax with P14:Thank you for purchasing Beginning Ajax with . We know that you have a lot of options when selecting a programming book and are glad that you have chosen ours. We’re sure you will be pleased with the relevant content and high quality you have come to expect from the Wrox Press line of books. | Professional Library Notice the number of parameters that you re passing into the method. There are now five parameters where before there were only three. The server-side method accepts only three so how can this work Remember that this is actually a JavaScript proxy object that is created by the Pro library for you to use. Every proxy object that is created is created with a couple of overloads. An overload is a variation of a method using the same method name but with a unique set of parameters known as a signature. The signature is defined as the order and types of the parameters the method accepts. The proxy object gets created with the following signatures. string string string string string string callback string string string callback context Notice the last two parameters callback and context. callback is the name of the method that you want the response to be sent to. In this example you would have a problem if all you could work with in the callback method was the response from the server. You d have a problem because you need to set the value of the image tag and you wouldn t know what that image tag was. So Pro has a last parameter called context. Whatever object you pass in as the context parameter will be returned in the response object as its context property. Remember the response object has five properties value error request extend and context. Now you see where the context is helpful. The context basically gets a free ride from your execution point where you ask for the server method to be called into your callback method. It is common to name the callback function the same as the original function name with the _Callback appended to it. Take a look at this callback function. function ChangeMe_Callback response if null alert

TỪ KHÓA LIÊN QUAN