Hello i have a working ajax that works fine with my controller, in case you need t check if ours is working try$this-:request->IsAjax()
;
(function(){
var $forms = $("form[role='form']");
$forms.each(function(){
var $form = $(this);
$form.submit(function(){
var $this = $(this),
action = $this.attr("action"),
method = $this.attr("method"),
inputs = $this.find("input:not(:file):not(:submit) , textarea"),
files = $this.find("input:file"),
content = new FormData( $this );
// Loop & append inputs
for( var i = 0; i < inputs.length ; ++i )
{
content.append( $(inputs[i]).attr("name") , $(inputs[i]).val() ); // Add all fields automatic
}
// Loop & append files with file data
if( files.length ) {
for( var i = 0; i < files.length ; ++i )
{
if(files[i].files[i] != undefined)
{
content.append(files.eq(i).attr("name"), files[i].files[i], files[i].files[i].name );// add files if exits
}
}
}
// Submit data
$.ajax({
url: action, // Action ( PHP SCRIPT )
type: method, // Method
data: content, // Data Created
processData: false, // Tell jQuery not to process the data
contentType: false, // Tell jQuery not to set contentType
dataType: "json", // Accept JSON response
cache: false, // Disale Cashing
success: function( response )
{
// use the response
}
});
return false;
});
});
})();