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:

  1. ; missing @ end of variable assignment
  2. read values input fields using val() instead of getting jquery objects of them
  3. 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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -