简单查询的ajax错误?

时间:2014-03-30 17:58:30

标签: javascript php jquery ajax

为什么以下引发错误?

$.ajax({
    type: "GET",
    url: str,
    crossDomain: true,
    timeout: 5000,
    success: function(data) {
        console.log(data);
    },
    error: function(error) {
        console.log(error.statusText);
    },
});

变量str的值为"http://deepview.info/getTableData.php?uid=5405&exchange=NASDAQ&symbol=MSFT&startDate=1391212800&endDate=1393632000"

我真正需要的是将输出保存到json文件......

1 个答案:

答案 0 :(得分:0)

尝试这个

str = "http: //deepview.info/getTableData.php";
formData = {
    uid: "5405",
    exchange: "NASDAQ",
    symbol: "MSFT",
    startDate: "1391212800",
    endDate: "1393632000"
}
$.ajax({
    type: "GET",
    url: str,
    crossDomain: true,
    data: formData,
    contentType: 'application/json',
    dataType: "json",
    success: function(data) {
        console.log(data);
    },
    error: function(response) {
        console.log(response);
    },
});