Pass parameter to Ajax call to use after response returns

Let’s say I have some data I want to pass along with an ajax call to use when the response comes in. You can pass round trip parameters in your jQuery ajax call by adding them to the options object like this

 url: '',
 dataType: "json",
 roundTripVariable: 'Weeeeee!',
 success: function(data, textStatus, jqXHR) {
 // will print 'Weeeeee!' to the console
 console.log( this.roundTripVariable );

Published by


I am a Geek! I hope you enjoyed this recent post.