Back

Standard Ajax

Copy Below Code View As A Text File Show Text Only Show API Edit Code
                            

function submitMyForm(frm,contr,func,rf,alertmsg){ var pageName =base_url+base_url_admin+"/"+contr+"/"+func; $("#loader_div").show(); $(".subm").attr('disabled',true); var btnText=$(".subm").html(); $(".subm").html('<i class="fa fa-refresh fa-spin" aria-hidden="true"></i> Processing'); $("#loader_div").html('<img src="'+base_url+'public/images/admin_images/loader_gif.gif" />'); $.ajax({ type: "POST", timeout: 200000, url: pageName, //data: parameters, data: new FormData(frm), contentType:false, cache: false, // To unable request pages to be cached processData:false, beforeSend: function(){}, success: function(msg){ $(".subm").attr('disabled',false); $(".subm").html(btnText); if(isJson(msg)==false){alert('ERROR::'+msg);$("#loader_div").hide();return false;} obj = JSON.parse(msg); if(obj.success=='done'){ if(func=='post_edit_cheque') { $('#myModal').modal('show'); getAddFuncDiv('Cheque Payments', 'affiliate','cheque_payments',frm.elements["aff_id"].value); return true; } else { $("#loader_div").hide(); $('#myModal').modal('hide'); $("#add_page_form").modal('hide'); $(".subm").attr('disabled',false); if (typeof(alertmsg)!='undefined'){ alertme('<i class="fa fa-check" aria-hidden="true"></i> '+alertmsg,'success',true,3000); } } if(rf==true){location.reload();} } else{ $("#loader_div").hide(); $(".subm").attr('disabled',false); alert(obj.errormsg); } }, error: function(jqXHR, textStatus, errorThrown) { $(".subm").html(btnText); $("#loader_div").hide(); $(".subm").attr('disabled',false); if(textStatus==="timeout") { alert("ERROR: Connection problem"); //Handle the timeout } else { alert("ERROR: There is something wrong."); } } }); }