简体   繁体   English

Ajax获取带有JQuery错误的请求

[英]Ajax Get Request with JQuery Error

I'm trying to call a php script with a get request and using the data theaddress however the results are showing me the source of the page im calling. 我正在尝试使用get请求调用php脚本,并使用datatheaddress数据,但是结果向我显示了im调用页面的源代码。

The page im calling is here Here is my ajax function that will get this page 我正在调用的页面在这里这是我的ajax函数,它将获取此页面

    $( document ).ready(function() {
        var address = document.getElementById("address");

     $.ajax({
      url: '/r10database/checkSystem/ManorWPG.php',
      type: 'GET',
      data: 'theaddress='+address.value,
      cache: false,
      success: function(output) 
      {
          alert('success, server says '+output);
      }, error: function()
      {
        alert('Something went wrong, saving system failed');
      }
   });



    });
$( document ).ready(function() {
    var address = document.getElementById("address");

 $.ajax({
  url: '/r10database/checkSystem/ManorWPG.php',
  type: 'GET',
  data: 'theaddress='+address.value,
  cache: false,
  success: function(output) 
  {
      alert('success, server says '+output);
  }, error: function(error)
  {
    alert (error); // this is the change from the question
  }
});
});

Put the dataType as json with a curly brace 用大括号将dataType作为json

data: {theaddress:address.value},
dataType:'json',
success: function(output) 
{
    alert('success, server says '+output);
}, error: function(xhr)
{
   alert (xhr.status);
}

and get the data in ManorWPG.php as $_GET['theaddress'] 并以$ _GET ['theaddress']的形式获取ManorWPG.php中的数据

** share the xhr.status if failed. **如果失败,请共享xhr.status。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM