开发者

How do I see the url that I'm using in $.getJSON

开发者 https://www.devze.com 2023-04-06 03:13 出处:网络
开发者_JS百科I have the following code snip and am trying to debug it. Is there a way to get the full url string that the .getJSON call is calling?

开发者_JS百科I have the following code snip and am trying to debug it. Is there a way to get the full url string that the .getJSON call is calling?

opts = {};
opts['start'] = startdate;
opts['end'] = enddate;
opts['email'] = addresses;
$.getJSON(url_count_string, opts, function(data){
   drawChart(data, chartsData['hourChart']);
});


Firefox w/Firebug - "Net" tab.

Chrome - "Network" tab.

IE9 - "Network" tab.

Safari - "Network" tab.

Opera - Dragonfly "Network" tab.


if your url_count_string is relative & what you want to see if full url, then append url_count_string to current path.

If what you want to see is url with request params appended (x=123&y=456....), try to see XHR Net Panel in Firebug.


You know that the method is making a GET request, so it must be appending the data in the standard way.

Using this answer, we can do this:

function createGetParams(data) {
  var ret = [];
  for (var d in data) {
    ret.push(encodeURIComponent(d) + "=" + encodeURIComponent(data[d]));
  }
  return ret.join("&");
}

var finalURL = url_count_string + '?' + createGetParams(opts);

Assuming the opts array and url_count_string variables are defined as they are in your question.

finalURL will be the URL that jQuery is sending the request to.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号