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

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -