javascript - How to get data from one php page using ajax and pass it to another php page using ajax -
i trying data 1 php page , pass page using ajax.
js :
$.ajax({ url: "action.php", success: function(data){ $.ajax({ url: "data.php?id=data" } });
action.php :
<?php $test= 1; ?>
data.php :
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script type="" src="action.js"></script> <?php $id = $_get['id']; echo $id; ?>
first of all, need echo
data in action.php, , second, use data
parameter of ajax request send data data.php.
here's reference:
so organization of pages should this:
js :
$.ajax({ url: "action.php", success: function(data){ $.ajax({ url: "data.php", data: {id: data}, success: function(data){ // code // alert(data); } }); } });
action.php :
<?php $test = 1; echo $test; ?>
data.php :
<?php $id = $_get['id']; echo $id; ?>
Comments
Post a Comment