0

Why does the following throw an error?

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

The value of the variable str is "http://deepview.info/getTableData.php?uid=5405&exchange=NASDAQ&symbol=MSFT&startDate=1391212800&endDate=1393632000"

What I really need is to save the output to a json file...

Peter Hall
  • 53,120
  • 14
  • 139
  • 204
user1357015
  • 11,168
  • 22
  • 66
  • 111

1 Answers1

0

try this one

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);
    },
});
Nurdin
  • 23,382
  • 43
  • 130
  • 308