I'm wanting to log the fully constructed url string of a jQuery.ajax call.I'm setting the params in the data variable of the ajax command, like so:
jQuery.ajax({
url: 'http://a.site.com',
data: {
format: 'json',
name: 'John Smith',
addressdetails: 1
},
beforeSend: function(jqXHR, settings) {
console.log(jqXHR, settings); // Can't find it in these values
},
success: function(data, textStatus, jqXHR) {
console.log(data, textStatus, jqXHR); // Nor in these
}
});
What I would be looking for in the logs from the example above is this string:
'http://a.site.com?format=json&name=John%20Smith&addressdetails=1'
I feel like there must be something I'm missing. I'm convinced it will be in one of the callback functions, but can't for the life of me find it anywhere. Any help appreciated.
settings.url
See snippet:
$.ajax({
url: 'http://google.com',
data: {
format: 'json',
name: 'John Smith',
addressdetails: 1
},
beforeSend: function(jqXHR, settings) {
document.write(settings.url);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With