how get php respone from jquery .load

后端 未结 1 1553
难免孤独
难免孤独 2021-01-26 00:45

i give another codes for example this is my some3.php code:(First file) :




        
相关标签:
1条回答
  • 2021-01-26 01:38

    Well, assuming that you want to read the value with JQuery off the page you are posting to, you could do this, since you are echo'ing the value out in that page by doing the following: echo $myVariable; Now this is how I generally read a value off another page with JQuery which is by using JQuery's get() method.

    $.get("thepagetoretrievefrom.php", function(retrievedvalue) {
        alert("Here's the data you requested: " + retrievedvalue);
        if (retrievedvalue == 1)  {
            //print out something here
            alert("The retrieved value was 1.");
        }
    });
    

    And that should retrieve the value from the PHP page. "thepagetoretrievefrom.php" is the page where you want to retrieve the information from. function(retrievedvalue) just indicates that whatever output you're requesting from the page via JQuery will be put into retrievedvalue. Then, using JQuery, you may decide whether you want to do a new call to another page depending on what the "retrievedvalue" was. This, however is not the best method to achieve this, since this will print whatever may be in that page, but if you are requesting one specific value from that page, then it shouldn't be an issue.

    0 讨论(0)
提交回复
热议问题