php - jQuery.ajax response data giving null -
i trying insert data mysql database using jquery , ajax. have written query parameters in add.php file. show form data immediatly beneath form.
jquery:
jquery("#addstockinform").submit(function(e){ e.preventdefault(); datastring = jquery("#addstockinform").serialize(); jquery.ajax({ type: "post", url: "add.php", data: datastring, datatype: "json", success: function(data) { //$("div#showinstant").html(data); alert(data); } }); });
add.php file
require 'foo.config.php'; if(isset($_post['addstockin'])) { $query = "insert stockin ( serialno, project_id, ...... etc. ) values (`:serialno, :project_id, ....... etc. )";
add-stockin.php file
<form class="form-horizontal" id="addstockinform" method="post"> ..... </form>
you should return data php code frontend
require 'foo.config.php'; if(isset($_post['addstockin'])) { $query = "insert stockin ( serialno, project_id, ...... etc. ) values (`:serialno, :project_id, ....... etc. )"; ... ... echo yourdata
Comments
Post a Comment