How to get a cross-origin resource sharing (CORS) post request working

后端 未结 11 2248
野趣味
野趣味 2020-11-21 22:35

I have a machine on my local lan (machineA) that has two web servers. The first is the in-built one in XBMC (on port 8080) and displays our library. The second server is a

11条回答
  •  無奈伤痛
    2020-11-21 23:35

    This is a little late to the party, but I have been struggling with this for a couple of days. It is possible and none of the answers I found here have worked. It's deceptively simple. Here's the .ajax call:

        
        
        
        
         Javascript Test
         
          
        
        

    Here's the php on the server side:

        
        
         PHP Test
         
        
          connect_error) {
            die( "Connection failed: " . $conn->connect_error);
          }
          $sql = "SELECT email, status, userdata  FROM msi.usersLive";
          $result = $conn->query($sql);
          if ($result->num_rows > 0) {
          while($row = $result->fetch_assoc()) {
            echo $row["email"] . ":" . $row["status"] . ":" . $row["userdata"] .  "
    "; } } else { echo "{ }"; } $conn->close(); ?>

提交回复
热议问题