【问题标题】:Javascript ajax call uncaught reference errorJavascript ajax 调用未捕获的引用错误
【发布时间】:2012-12-09 21:40:04
【问题描述】:

您好,我有一个 php 应用程序,但我的 javascript 导致错误,它在 localhost 上完美运行,但是当我上传到亚马逊 elasticbeanstalk 时,它显示此错误Uncaught ReferenceError: getEvent is not defined 这是我的代码:

index.phtml

<script type="text/javascript" src="../public/js/page/home.js"></script>
$(document).ready(function(){
getEvent();
});

home.js

function getEvent()
{
    var count=1;
    $.ajax({
        url:baseUrl + "event/popularevent",
        data:{'count':count},
        dataType:"json",
        type:"POST",
        async:false,
        success:function(data){
            var eventHtml = '';
            eventHtml = '<li class="clearfix media-block module-li">' +
                    '<div class="media-avatar-passport">' +
                        '<div class="photo-box pb-60s">' +
        '<a class="event-photo" href="/events/san-francisco-halloween-beer-olympics-halloween-drinking-games-1-beer-free">' +
            '<img class="photo-img" alt="Photo of HALLOWEEN BEER OLYMPICS! Halloween Drinking Games + $1 Beer!  FREE!" height="60" src="#" width="60"></a></div>' +

        '</div><div class="media-story">' +
                '<div class="item-title clearfix">' +
        '<a href="/events/san-francisco-halloween-beer-olympics-halloween-drinking-games-1-beer-free" class="url summary">HALLOWEEN BEER OLYMPICS! Halloween Drinking Games + $1 Beer! &nbsp;FREE!</a></div>'+

        '<div class="item-description">'+
        '<span class="extra">'+
        '   Tomorrow, Oct 26, 8:30 pm'+
        '</span><p class="fine-print">140 are interested</p></div>'+
        '</div></li>';
            //alert('ok');
            $('#popular-events .module-list').html(eventHtml);
        }
    });
}

我犯了一个错误,它在本地主机上而不是在部署服务器上运行没有错误的问题。谢谢

【问题讨论】:

  • 您检查过您的 ajax-url 的权限吗?
  • 这是怎么回事..?它适用于本地主机..

标签: php javascript ajax amazon-elastic-beanstalk


【解决方案1】:

如果不看环境很难判断,但我猜两件事之一正在发生。

home.js 上传到错误的位置或文件权限设置错误

【讨论】:

  • 但我还有其他功能也以类似的方式请求但它有效..?
  • 嗯,所以您调用了 home.js 中另一个正在工作的函数?您最近是否将 getEvent() 添加到 home.js?也许它只是一个缓存问题。
猜你喜欢
  • 1970-01-01
  • 2014-10-11
  • 1970-01-01
  • 2018-10-23
  • 2018-06-27
  • 1970-01-01
  • 2013-04-10
  • 2019-10-25
  • 2017-06-16
相关资源
最近更新 更多