Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

x editable and codeigniter: display error message if data not updated into db

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

like image 700
user3154773 Avatar asked Nov 11 '22 15:11

user3154773


1 Answers

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 !')
}
like image 174
ReNiSh AR Avatar answered Dec 26 '22 08:12

ReNiSh AR