ajax - show success message on same page after adding recording without reloadin the site in cakephp 2.x -
i want add show sucess message using :-
session->flash(); ?> in view , added message in controller :- session->setflash("record has been saved successfully."); ?>
but donot want reload whole page. inserting new record using ajax.. , refreshing div having list of record. session->flash(); ?> works if reload whole page. how can show message once record saved using ajax.
solutions (i recommend first one):
create ajax method in controller return 200 code json/html record's data or other error code if sth goes wrong. in js do:
$.ajax({ ... }).done(function( data ) { // success, show record , message $('#flash').text('success!').show(); // ... }).error( function() { // error $('#flash').text('error!').show(); });
refresh records list calling ajax method , return not view list of records, flash message (in same view). show or move using javascript.
Comments
Post a Comment