Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access the URL of an jQuery Ajax Request in the Callback Function

Is there a way that I can see the URL that was requested when I do an Ajax request with jQuery?

e.g.,

var some_data_object = { ...all sorts of junk... } $.get('/someurl.php',some_data_object, function(data, textStatus, jqXHR) {    var real_url = ? # <-- How do I get this }) 

How can I access the URL that jQuery actually used to make the request? Perhaps some method/property of jqHXR? I couldn't find it in the documentation.

Thanks.

like image 906
Chris W. Avatar asked Mar 29 '11 05:03

Chris W.


People also ask

How do I get Ajax call URL?

The $. ajax() Function. The url parameter is a string containing the URL you want to reach with the Ajax call, while settings is an object literal containing the configuration for the Ajax request. In its first form, this function performs an Ajax request using the url parameter and the options specified in settings .

What is URL in jQuery AJAX?

url: A string URL to which you want to submit or retrieve the data. options: Configuration options for Ajax request. An options parameter can be specified using JSON format. This parameter is optional.

What is callback jQuery Ajax?

jQuery - ajaxSuccess( callback ) Method The ajaxSuccess( callback ) method attaches a function to be executed whenever an AJAX request completes successfully. This is an Ajax Event.

How do you check Ajax URL is working or not?

ajax() : $. ajax({ type: 'POST', url: 'page. php', data: stuff, success: function( data ) { }, error: function(xhr, status, error) { // check status && error }, dataType: 'text' });


1 Answers

Set a break point in success method, then watch

this.url 

is the real url for the request.

like image 182
airbai Avatar answered Sep 23 '22 05:09

airbai