To create a XMLHTTP with JScript HTML

Source: Internet
Author: User
Tags xsl xsl file xsl stylesheet
To create a XMLHTTP with JScript HTML
Dear GUI DR:
I have a question about XML. I publish an ASP page through XMLHTTP, send the data back as HTML, and execute object.innerhtml on the div, table cell, or any element.
The problem I encountered was that once I created a form on the ASP Server page and sent it back in HTML, doing everything right. But I also want to do client-side validation on this page, so I put a JScript page link in the body of the response HTML I'm going to send back. After doing this, the script will not run.
When I include the actual JScript src reference on the parent page, it works correctly. Is this because JScript code is not loaded into the Run-time library? Can I not return the JScript code and make it work correctly in response to XMLHTTP post? Can you generate a JScript function for the page you create instantly?
I have not tried to do this in a different way: by XMLHTTP the XML data, and then sending it back as XML data, and then using the XSL stylesheet for conversion. I suspect that the JScript function can be defined in that way. But this approach seems too complicated. Do you have any suggestions or answers?
Thank you
Peter Sung
Dr GUI's reply:
Yes, Peter, you can return Microsoft JScript code in response to XMLHTTP Post/get and make the code executable. It's like getting a piece of cake first and then eating it. As you can guess, the best way to do this is to take advantage of the XSL style sheet, which is easy once you have all the types back to normal. The GUI doctor can even provide a quick example. (Of course, there are other solutions as well.) As long as the response contains the correct headers and characters in the correct order, the browser will interpret the response so that the response is working correctly. If necessary, you can generate a response with a string connection. )
In the following example, Dr. GUI is used in the ASP page for client code and VBScript (Microsoft Visual Basic scripting version). The strategy is this: the XML file contains only data (and references to style sheets). The XSL file contains all the HTML formats that are necessary to make up the full page, including the script located in the appropriate location. ASP pages consist primarily of calls to create a XMLHTTP object, load an XML file into the object (using an implicit style sheet), and write the resulting HTML to the response stream.
To try this method, follow the simple steps shown below. Copy and paste with Notepad, and save all files in C:inetpubwwwroot.
1.
Create a file that contains the following XML text and is named Books.xml. Note the reference to the Books.xsl style sheet. In addition, this file contains only data.
<?xml version= "1.0"?>
<?xml-stylesheet type= "text/xsl" href= "Books.xsl"?>

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.