To display data on other websites on your own page, you need to use Ajax to solve cross-origin problems,
Solution: jQuery. support. cors = true; (the browser supports cross-origin access ),
Instance:
Copy codeThe Code is as follows:
// The browser supports cross-origin access
JQuery. support. cors = true;
$. Ajax ({
Url: "http://www.rj99999.com/Price/ListPrice.html ",
DataType: 'html ',
Success: function (data, textStatus ){
// NowPrice is the data control displayed on this page, # price'. data is used to retrieve the element named price from other websites.
$ ("# NowPrice"). text (jQuery ('# price', data).html () + "Yuan/gram ");
},
Error: function (xhr, ajaxOptions, thrownError ){
$ ("# NowPrice"). text ("Temporarily unavailable ");
}
});
// Real-time refresh
// Call the togglecountdowntime () method every 60000 milliseconds/minute.
SetTimeout ("togglecountdowntime ()", 60000 );