我正在尝试使用yahoo api获得从USD到MXN的简单汇率,但我没有得到任何回报,这只是一个CORS问题还是我错误地访问了该属性?
var exchangeRateURL = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20%28%22USDMXN%22%29&env=store://datatables.org/alltableswithkeys";
//Get current USD->MXN exchange rate
$.getJSON(exchangeRateURL, function(data)
{
priceInMXN = data.query.results.rate.Rate;
document.write(priceInMXN);
});
提前致谢!
答案 0 :(得分:3)
您正在获取XML,而不是JSON。这样的事情会起作用:
$.get(exchangeRateURL, function(data) {
console.log($(data).find('Rate').text());
});
答案 1 :(得分:3)
传递一个参数以返回JSON(& format = json):
foreach (GridViewRow r in grdtemp.Rows)
{
TextBox No = (TextBox)r.FindControl("txtNo");
TextBox ActiveFlag = (TextBox)r.FindControl("txtActvFlag");
TextBox Folder = (TextBox)r.FindControl("txtFolder");
int j = Bll.DbClass("insert into MSTBackupCtr_Folder
values(no,flag,folder) values ('"+No.Text+"','"+ActiveFlag.Text+"','"+Folder.Text+"')");
//BLL.DbClass is my custom class for Data insertion
}