jquery ajax returns error but is success
You need to return json from controller, as this is what jQuery expects. You can return i.e.
{ success : true }
Or you could set html as data type (maybe it will work without content but you may need to return something)