ASPnet jquery Ajax XML cross-origin read

Source: Internet
Author: User
Tags in domain

The Methods circulating on the Internet are basically Java's kind of jsonp. The idea of ASPnet reading is similar.

Comment. xml

<? XML version = "1.0" encoding = "gb2312"?>
<Root>
<Comment>
<URL> http://image.meimumeijia.com/product_comment/2013/08/327956_201308161103132272_small.jpg </URL>
<DESC> test the function! </DESC>
</Comment>
<Comment>
<URL> http://image.meimumeijia.com/product_comment/2013/08/327956_201sdfsdf272_small.jpg </URL>
<DESC> test and test sdfs! </DESC>
</Comment>
</Root>

1. Use the comment. xml configuration file of B in Domain.

JS

Function readnewcomment (){
$. Ajax ({
URL: "/common/control/getcommenthandler. ashx ",
Cache: false,
Async: True,
Datatype: "XML ",
Type: "Get ",
Timeout: 2000,
Error: function (XML ){
Alert ("An error occurred while loading the XML file! ");
},
Success: function (XML ){
$ (XML). Find ("root"). Each (function (){
$ (This). Find ("comment"). Each (function (){
VaR url = $ (this). Children ("url"). Text ();
VaR DESC = $ (this). Children ("DESC"). Text ();
Alert (URL + "," + DESC );
})
});
}
})
}

2. Create a general handler in Domain.

Ashx

String url = @ "http://www.4inlook.cn/Product/comment.xml ";
Xmltextreader reader = new xmltextreader (URL );
Xmldocument XD = new xmldocument ();
XD. Load (Reader );
Context. response. Write (XD. innerxml );

3. Request XML in a general processing program and return the requested object to Js for processing

Related Article

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.