Jump to content
Sign in to follow this  
krrish

passing multiple data through ajax

Recommended Posts

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 by krrish

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...