javascript - Keep form window open when form is submitted -


consider image iframe window when user clicks on link.

enter image description here

my problem

when user clicks deposit form gets submitted , the window closes, user not know if deposit successful or not.

what want do

i looking way keep iframe window open after form has been submitted, display appropriate message

form html

   <form name="depform" action="" id="register_form" method="post">             user name<br /><input type="text" name="uname" value="" /><br />             credit card nr<br /><input type="text" name="cc" value="" /><br />             csv nr<br /><input type="text" name="csv" value="" /><br />             amount<br /> <input type="text" name="amount" value="" /><br />             <input type="submit" value="deposit" name="deposit" class="buttono" />             </form> 

php code

if(isset($_post['deposit'])){             if(isset($_session['fbid'])){                 $uid=$_session['fbid'];                 $amount = $_post['amount'];                 $cc = $_post['cc'];                 $csv = $_post['csv'];                 //new bal                 $bal = getbal($uid);                 $newbal = $bal+$amount;                 $sql="update members set balance='$newbal' member_nr='$uid'";                 $result = mysql_query($sql) or die("error please try again");                        if($result){                      }             } 

if can advise me how keep iframe open after form has been submitted appreciated.

you need change form submission use ajax. in response can include state flag indicate ui whether request successful or not , act appropriately. this:

$('#register_form').submit(function(e) {     e.preventdefault(); // stop standard form submission     $.ajax({         url: this.action,         type: this.method,         data: $(this).serialize(),         success: function(data) {             if (data.success) {                 // show success message in ui and/or hide modal             } else {                 // didn't work             }         },         error: function(xhr, status, error) {             // went wrong server. diagnose above properties         }     }); }); 
$success = false; if (isset($_post['deposit'])) {     if (isset($_session['fbid'])) {         $uid = $_session['fbid'];         $amount = $_post['amount'];         $cc = $_post['cc'];         $csv = $_post['csv'];          $bal = getbal($uid);         $newbal = $bal + $amount;         $sql = "update members set balance='$newbal' member_nr='$uid'";         $result = mysql_query($sql) or die("error please try again");            if ($result) {             $success = true;         }     } }  echo json_encode(array('success' => $success)); 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -