doulilou8560 2010-03-13 00:46
浏览 56
已采纳

PHP应该生成什么来回馈jQuery AJAX请求?

Perhaps it's a syntax error, but I never assume that. I have a -dead- simple AJAX test set up:

http://www.mcphersonindustries.com/bucket/api.php is a file with simply:

<?php echo "test"; ?>

And I have Apache as localhost with this jQuery bit running:

$(document).ready(function() {

function doAjaxPost() {  
    $.ajax({  
       type: "POST",  
       url: "http://www.mcphersonindustries.com/bucket/api.php",  
       data: "null",  
       success: function(resp){   
           console.log("Response: '" + resp + "'");  
       },  
       error: function(e){  
           console.log('Error: ' + e);  
       }  
    });  
}  

doAjaxPost();

});

So Firebug spits out Response: '' each time, but nothing's coming through the request. Do I need to declare a header in PHP? Am I making a boneheaded mistake somewhere?

Thanks for the insights, as always.

  • 写回答

5条回答 默认 最新

  • dongyi8383 2010-03-13 00:54
    关注

    You can't do cross-site AJAX without that domain authorizing you:

    http://ejohn.org/blog/cross-site-xmlhttprequest/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了