php - Unable to post variables with jquery post() -
i trying pass variables modal form page. declare variables form id tags in each selection.
page reloads test.php, no variable can echoed.
javascript
var id = $( "#id" ), name = $( "#name" ) $.post("jqtest/test.php", { device_id: "id", device_name: "name" }); load('jqtest/test.php');
test.php
echo $_post['device_name']; echo $_post['device_id'];
it's not clear how planning use code pass values modal form there several problems current code:
;
missing @ end of variable assignment- read values input fields using
val()
instead of getting jquery objects of them - use variable names in data object of post method instead of literals ("id", "name")
try see variables passed , echoed in callback function
var id = $( "#id" ).val(), name = $( "#name" ).val(); $.post("jqtest/test.php", { device_id: id, device_name: name }, function(data){ alert(data); } );
Comments
Post a Comment