weixin_33695450 2012-09-11 14:37 采纳率: 0%
浏览 48

jQuery Ajax无法获得响应

Have problem with this code

var MAIN_LOCATION = "http://www.bosscaffe.com/new/";
$("#gallery_page").click(function() {
    $('#gallery_photos').show();
    getPhotos();
    return false;
}); 

function getPhotos()
{
    $.ajax({
         type: "GET",
         url: MAIN_LOCATION + "classes/getEnterijerPhotos.php?lang="+LANG,
         success: function(msg){
            if (msg != 'nothing')
            {
                $('#photo_wrapper').empty();
                $('#photo_wrapper').append(msg);
            }
         }
    });
}

I tried several things like crossdomain: true, async:false, etc...I tried to switch it to POST, but from some reason this one does not return anything if I fire call in new tab, I get result http://www.bosscaffe.com/new/classes/getEnterijerPhotos.php?lang=en so all of those images are prepared, on my local instance this works but on server it doesn't at all, in Chrome I get status = canceled, any thoughts about this one?

In any case end solution would be to transfer it to JSON, but strange thing that such a functionality not working on same domain.

  • 写回答

2条回答 默认 最新

  • 零零乙 2012-09-11 14:56
    关注

    You don't provide enough information to answer your question but here are a few things to consider:

    There is a typo in your first line where you have an extra 'l' (el) in galllery.

    As previously noted, if you expect the reply to be a particular datatype, you need to list it in the arguments to $.ajax() so the code can prepare its result properly.

    And it's usually a good idea to provide an error handler on all AJAX requests so you know the request has actually succeeded. In your code, your request can fail ("silently") without giving you any indication of the fact.

    EDIT

    If you're making the request from the same host that is running your PHP server process, I suspect you'll need to use the server's fully qualified hostname rather than 'localhost' in your URL.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算