i new jquery. want open form in popup dialog. when user submits form data should inserted mysql database & success message should displayed in dialog.
i dialog form how load success message?
<head> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css"> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script> </head> <body> <button id="dialog_trigger">open dialog</button> <div id="dialog" style="display:none;" title="dialog title"> <form id="form1"> <input type='text' name='data' id='data'/> <input type='submit' id='submit'/> </form> </div> <script> $( "#dialog_trigger" ).click(function() { $( "#dialog" ).dialog( "open" ); }); $("#dialog").dialog({ autoopen: false, position: 'center' , title: 'edit', draggable: false, width : 350, height : 200, resizable : true, modal : true, }); $( "#submit" ).click(function() { // }); </script> </body>
php:
$data=$_request['data']; $q= mysqli_query($c,"insert report (data) values ('$data')") or die(mysqli_error()); if($q){ echo "your report submitted!"; //this should appear in popup dialog }
use jquery form plugin or similar submit data via ajax call.
your data entry point should return json encoded value, example
echo json_encode(array('message' => 'thank submission'));
now, javascript side use returned message fill modal content, like
$("#message").text(message);
Comments
Post a Comment