How to get data from one php page using ajax and pass it to another php page using ajax

后端 未结 4 526
野性不改
野性不改 2021-01-22 08:45

I am trying to get data from one php page and pass it to another page using Ajax.

JS :

$.ajax({
      url: \"action.php\",
      succes         


        
4条回答
  •  星月不相逢
    2021-01-22 09:06

    First of all, you need to echo your data in action.php, and second, use data parameter of AJAX request to send data to data.php.

    Here's the reference:

    • jQuery.ajax()

    So the organization of pages should be like this:

    JS :

    $.ajax({
        url: "action.php",
        success: function(data){ 
            $.ajax({
                url: "data.php",
                data: {id: data},
                success: function(data){ 
                    // your code
                    // alert(data);
                }
            });
        }
    });
    

    action.php :

    
    

    data.php :

    
    

提交回复
热议问题