php - Unable to post variables with jquery post -
this question exact duplicate of:
- unable post variables jquery post() 2 answers
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'];
var id = $( "#id" ), name = $( "#name" ) /* if have tag <input id='id' value='abc'> , want abc , $( "#id" ).val(); if have tag <div id='id' >abc</div> , want abc,$( "#id" ).html(); */ $.post("jqtest/test.php", { device_id: "id", device_name: "name" }); /* after id , name , need $.post("jqtest/test.php", { device_id: id, device_name: name }); */ load('jqtest/test.php'); /* useless delete line if need callback, ref: $.post("test.php", { name: "john", time: "2pm" }) .done(function(data) { alert("data loaded: " + data); }); */
Comments
Post a Comment