如何在ajax中编写curl -XGET命令

时间:2017-06-20 21:12:34

标签: ajax curl

我正在运行此命令(这可行):

$ curl -XGET http://localhost:15439/logstash/thresholds

我想用AJAX编写。

$.ajax({
  url: "http://localhost:15439/logstash/thresholds",
  method: "GET",
  dataType: "json",  
  success: function(data) {
    var json_response = data;
        console.log("success");
      console.log(data);

  },
  error: function(error) {
    console.error(error);
  }
});

但它拒绝:

  

"选项http://localhost:15439/logstash/thresholds   净:: ERR_CONNECTION_REFUSED"

知道为什么吗?

当我运行curl -XGET -v http://localhost:15439/logstash/thresholds时,我得到:

* About to connect() to localhost port 15439 (#0)
* Trying ::1...
* Connected to localhost (::1) port 15439 (#0)
> GET /logstash/thresholds HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:15439 > Accept: */*
>
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< Content-Type: application/json; charset=utf-8
< Content-Length: 2510
< ETag: W/"H7IFEeDwS43oKpCDN92CPQ=="
< Date: Wed, 21 Jun 2017 07:32:57 GMT
< Connection: keep-alive

0 个答案:

没有答案