Every line of 'before send ajax' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
134 function beforeSend() { 135 var forms = $(".form-row"); 136 137 forms.each(function() { 138 var options = $(this).find("option") 139 options.each(function() { 140 if ($(this).attr("disabled")) { 141 $(this).attr("disabled", false); 142 } 143 }) 144 }); 145 return true; 146 }
71 function send(_, complete) { 72 var script = jQuery("
56 function beforeSend(jqXHR, settings){ 57 // show gif here, eg: 58 if(settings.url == 'postMetadata'){ 59 $("#loading-modal").modal({ 60 keyboard: false, 61 backdrop: 'static' 62 }); 63 var errors = checkMandatory(); 64 if(errors){ 65 closeModal(); 66 $("#error-message").text('Some of the Mandatory fields are not filled. Please verify your data and try again.') 67 $("#loading-alert").modal('show'); 68 jqXHR.abort(); 69 } 70 71 } 72 }
43 function executeAjax(form){ 44 if (!form.valid()) 45 return; 46 47 form.find(".submit").attr("disabled", true); 48 form.find(".cancel").attr("disabled", false); 49 50 var error = function(jqXHR) { 51 resetForm(form, false); 52 if (jqXHR.status == 400) { 53 errorPopup(Messages.get('error.occured'), form.parent(), "center-popup"); 54 return; 55 } 56 errorPopup(Messages.get('error.occured'), form.parent(), "center-popup"); 57 console.log(jqXHR); 58 }; 59 60 var success = function(response, status, jqhr) { 61 var target = $("#" + form.data("ajax-result")); 62 63 var action = form.data("ajax-on-callback") || "replace-inner"; 64 if (action == "replace-inner") { 65 target.html(response); 66 } else if(action == "append") { 67 target.append(response); 68 } else if(action == "replace"){ 69 target.replaceWith(response); 70 } 71 target.removeClass("hidden"); 72 73 resetForm(form, false); 74 bindAll(); 75 }; 76 77 var uri = form.attr("action"); 78 $.ajax(uri, { 79 success: success, 80 error: error, 81 dataType : 'html', 82 data : form.serialize(), 83 method: "POST" 84 }); 85 }
17 function ajaxBindCallback() 18 { 19 if (ajaxRequest.readyState == 4) 20 { 21 if (ajaxRequest.status == 200) 22 { 23 if (ajaxCallback) 24 { 25 ajaxCallback(ajaxRequest.responseXML); 26 } 27 else 28 { 29 alert('no callback defined'); 30 } 31 } 32 else 33 { 34 alert("There was a problem retrieving the xml data:\n" + ajaxRequest.status + ":\t" + ajaxRequest.statusText + "\n" + ajaxRequest.responseText); 35 } 36 } 37 }
2 function sendAjax(divname,ajaxurl,text,nextstep) 3 { 4 $.ajax({ 5 type: "GET", 6 url: ajaxurl, 7 success: function(msg){ 8 9 $(divname).html(msg); 10 11 var index = msg.indexOf(':'); 12 var prefix = ''; 13 var error = ''; 14 if(index>0) 15 { 16 prefix = msg.substr(0,index); 17 error = msg.substr(index+1); 18 } 19 20 if(prefix != "ERROR" && prefix != "WARNING") 21 { 22 $(divname).html(text+": "); 23 nextstep(); 24 } 25 else if(prefix == "WARNING") 26 { 27 $(divname).html(text+": "+error+" "); 28 nextstep(); 29 } 30 else 31 { 32 $(divname).html("An error as occured"); 33 } 34 }, 35 error:function (XMLHttpRequest, textStatus, errorThrown) { 36 alert(textStatus+' '+errorThrown); 37 } 38 39 }); 40 }
65 function run_ajax() { 66 // Ajax to get the json: 67 68 start_date = $('#start_date').val() 69 end_date = $('#end_date').val() 70 ticker = $("#ticker").find("option").filter(":selected").text(); 71 72 $.ajax({ 73 type: "GET", 74 dataType: 'json', 75 url: "/transactionsandcost_json?ticker=" + ticker + "&start=" + start_date + "&end=" + end_date, 76 success: function (data) { 77 $('#alerts').html("") 78 console.log("ajax request: OK") 79 console.log(data) 80 handle_ajax_data(data, ticker, data['fx']); 81 82 }, 83 error: function (xhr, status, error) { 84 $('#alerts').html("<div>An error occured while refreshing data." + 85 "<span>×</span></div>") 86 console.log(status); 87 } 88 }); 89 };
39 function setup_ajax(){ 40 41 try{ 42 43 xmlHttp=new XMLHttpRequest(); 44 45 }catch (e){ // Internet Explorer 46 47 try{ 48 49 xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 50 51 }catch (e){ 52 53 try{ 54 55 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 56 57 }catch (e){ 58 59 alert(AJAX_FAIL); 60 return false; 61 } 62 } 63 } 64 }
15 function doAjax(method, url, callback) { 16 if (window.GM_xmlhttpRequest) { 17 GM_xmlhttpRequest({ 18 method: method, 19 url: url, 20 onload: callback, 21 }); 22 } else { 23 var xhr = new XMLHttpRequest(); 24 xhr.onreadystatechange = function() { 25 if (xhr.readyState !== 4 || xhr.status !== 200) return; 26 callback(xhr); 27 }; 28 xhr.open(method, url, true); 29 } 30 }
32 function ajaxSuccess(response) { 33 if (response.status == 'success'){ 34 formValid(response.redirect_url); 35 } 36 else if (response.status == 'error'){ 37 formInvalid(response.form_errors); 38 } 39 }