Skip to content

Instantly share code, notes, and snippets.

@dineshpithiya
Created March 10, 2018 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dineshpithiya/f3a15ac74b82679754ef1d4dda7f7e71 to your computer and use it in GitHub Desktop.
Save dineshpithiya/f3a15ac74b82679754ef1d4dda7f7e71 to your computer and use it in GitHub Desktop.
function submit_form(formAction,formdata,form,callback,async=true)
{
$.ajax({
url : formAction,
data : formdata ? formdata : form.serialize(),
cache : false,
contentType : false,
processData : false,
type : 'POST',
async : async,
headers:
{
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
beforeSend: function()
{
//NProgress.start();
},
complete: function()
{
//NProgress.done();
//NProgress.remove();
},
success: function(data, textStatus, jqXHR)
{
//$("input[name=csrf_skill]").val(data.csrf);
callback(data)
},
error: function (xhr, status, error,data)
{
console.log(xhr.responseText);
//errorHandle(xhr.responseText);
alert("Can't do because: " + error);
},
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment