Remote Script document (reprinted from Microsoft) (Seven) _ Long distance scripting
Source: Internet
Author: User
Documentation: Checking for errors
When you invoke a method in a remote scripting server script, you may encounter several errors, including syntax errors and run-time errors, and errors when you invoke the remote scripting method. The remote scripting invocation mechanism gives you a way to learn about the error messages that occur during the call.
An error handler is slightly different depending on whether you are synchronizing or calling asynchronously. If you cause an error while making a synchronous call, the remote scripting mechanism displays an error message in the browser. The error text comes from the message property of the calling object. For more information, see "Remote Scripting Call Troubleshooting" below.
However, if you produce an asynchronous call that causes an error, you can catch the error by specifying an error callback function that has a large degree of similarity to the normal callback function.
To catch errors that occur in an asynchronous call
You can specify the name of the error callback function in your own asynchronous remote scripting call. Because you must pass the function pointer of the callback function, you must use JavaScript for asynchronous method calls. If you have created an object reference to a server page, you can use the first syntax example. Otherwise, you can use the second syntax example.
CallObject = Aspobject.methodname (P1, p2[,...],
Callbackfunction, errorcallbackfunction, context)
For more information about generating asynchronous calls to server methods, see calling the Remote scripting method asynchronously.
Regardless of whether you are synchronizing or calling asynchronously, you can get information about the error condition by testing the properties of the calling object. If the user specifies an error callback function, the calling object is passed as a parameter, just as the normal callback function parameter passes. In particular, the following properties provide an error message:
Status contains-1 if the remote call fails.
Data contains rough information about the XML format returned by the server. This is the best source of information for debugging because it contains the full text of the error message and other messages generated by the server.
The message contains information about the error messages (if any) generated by the remote Scripting Agent process. The error messages in the message are not necessarily the same as in the Data property. For example, if an ASP page contains a syntax error, a detailed message about the error will appear in the Data property, but the message property will contain only such a message-it indicates that the user cannot invoke the method on the ASP page.
The following script demonstrates an error callback function in the client script. The first script produces a remote scripting call and indicates the error callback function. The second script is the error callback function itself. The error callback function does not explicitly test the Call Object Status property value because the function is invoked only when the call fails.
function ShowErrors (CO) {
Dump Coarse data
msg = "The raw data returned by the remote method called is"
msg = msg + Co.data
Alert (msg);
Show friendly information
msg = "The following error occurred during the"
msg = msg + Co.context
msg = msg + "Remote Scripting call:\n"
msg = msg + co.message
Alert (msg);
}
</SCRIPT>
Remote Scripting Call Fault diagnosis
It is not always easy to find the exact source of the error in a remote scripting call, because remote scripting involves not only the customer but also multiple files on the server. However, some types of errors are generic and easy to spot. In addition, the user can use the remote scripting Mechanism's error capture program to obtain details of the error that occurred during the call.
In some cases, the user cannot perform any processing with the remote scripting because it has not been properly initialized. The following table lists the typical initialization errors and the possible causes of the error.
Symptoms may be wrong
Remote scripting does not work; The customer page source contains only <APPLET> tags. Rsenableremotescripting
The call is not in the document body. See Make the Remote scripting in the customer page valid.
Remote scripting does not work; all calls fail. ASP pages are not invoked. Use the http://protocol (not file://).
Client error messages, such as when attempting to invoke the remote scripting method, the "Undefined ' MSRs" message appears. The Rsenableremotescripting method could not be successfully invoked before attempting a remote call.
The client error message "Object does not support this property or method," especially the and. HTM file does not match the line number. The proxy object (Rsproxy.class) could not be found, or an invalid URL was passed in the Rsenableremotescripting method.
Client error message "Failed to create ASP object for file". An invalid URL was passed in the Rsgetaspobject call. See referencing ASP pages as objects.
If the error is in an ASP page that contains a remote invocation method, or if the error occurs during a call to a remote method, the user can catch the error in an error callback function, and the user can obtain information about the error from the data and message properties of the calling object.
The following table lists the typical issues that users can catch with the error callback function and the values in the message and data properties. In most cases, the message property returns general information, while the Data property contains detailed information about the error.
Note The Data property contains a number of XML tags and other information about the call. The following table lists a string that appears in the property value.
Problem message Value data value
Invalid URL for an ASP page in the Rsexecute method. See the synchronization call Remote scripting method and the asynchronous invoke remote scripting method, including the name of the page that the user is trying to invoke. (NULL)
ASP file to rs.asp path error. See Make the Remote scripting in the server page valid. "The called page does not support remote scripting. The include file was not found. ”
Syntax or run-time errors in the ASP file. "The called page does not support remote scripting. "The details about the error, including the line number.
An attempt was made to invoke a method that does not exist. "is not a public function. "" is not a public function. ”
The ASP constructor references a function that does not appear in the ASP file. See the page that makes remote scripting in Server Pages not support remote scripting. "" FunctionName not defined. ”
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.