Question

In my application I have a dataTable to display record from db, I am trying to edit record using x-editable and its working fine. But the problem is I want to display an error message if submitted data not updated successfully into the db.

I tried 'success:' but it triggered after submit the form whatever the data reach the db or not, but i want to trigger the success if controller return true.

Thanks

Was it helpful?

Solution

if you are processing the editable submission using ajax you need to set:

echo 1; //if model returns true

and

echo 0; //if model returns false    

in the controller.

Then in the ajax reponse you need to check in the script:

(Consider the response variable is response)

if(response==1)
{
  alert('Update Success.');
}
else
{
  alert('Update Failure !')
}

OTHER TIPS

This would be easier if you provided us with a code sample.

If you're working with ActiveRecord, you can always use:

if($this->db->affected_rows() > 0)
{
   return true;
}
else
{
   return false;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top