JS - Simple AJAX call and redirect

function _simpleAjaxCallAndRedirect(url, num) { $.ajax({ url: url, data: { id: num }, traditional: true, dataType: "json", type: 'POST', success: function (data) { if (data.url !== undefined) window.location.href = data.url; }, error: function (response) { } }); }
Performs an Ajax request to a specified url, and redirects to the returned url parameter.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.