php - json_encode issue -
i have code
if($_post){ // response hash $response = array('type'=>'', 'message'=>''); try{ // sort of data validations, simple example below $required_fields = array('name'); foreach($required_fields $field){ if(empty($_post[$field])){ throw new exception('field empty'); } } // ok, field validations ok // add data db, send email, ect. // let's assume ok, setup successful response $response['type'] = 'success'; $response['message'] = "done"; }catch(exception $e){ $response['type'] = 'error'; $response['message'] = $e->getmessage(); } // ready turn hash json print json_encode($response); exit; }
and want redirect page ( ok.html ) after 'success'. how can make it
regards
you can redirect page:
window.location = 'ok.html';
but better change current page content using javascript.
Comments
Post a Comment