krrish Posted September 19, 2013 Share Posted September 19, 2013 (edited) I need to pass multiple data through ajax, and also should post back it in another page. but my code is not working, this is my code: var data = {page_num: page,gender: <?php echo $gender;?>this_year: <?php echo $year;?>};$.ajax({ type: "POST", url: "data.php", data: data, success: function(res) { $("#result").append(res); console.log(res); } }); POST the values(data.php): echo $page = $_POST['page_num'];echo $gender = $_POST['gender'];echo $fromyear = $_POST['this_year']; please guys help me. thnx, Edited September 19, 2013 by krrish Link to comment Share on other sites More sharing options...
birbal Posted September 19, 2013 Share Posted September 19, 2013 check the data, dump it in console.log(). verify the data it is sending to the data.php. unless you are using a php page to generate JS page, <?php echo $gender;?> this wont work. php code block only execute in php context. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now