Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function redirectAjax(params, successCallback) {
- params.success = function(response) {
- var pattern = /^(https?:\/\/)?[a-z0-9_\.\/]+/i;
- var check = pattern.test(response);
- if (check !== false) {
- window.location.replace(response);
- } else {
- successCallback(response);
- }
- };
- params.error = function(response) {
- console.log('ajax error:' + response.data);
- };
- $.ajax(params);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement