Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/427.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ajax请求在本地工作,但不在实时服务器上工作_Javascript_Php_Jquery_Ajax_Laravel - Fatal编程技术网

Javascript ajax请求在本地工作,但不在实时服务器上工作

Javascript ajax请求在本地工作,但不在实时服务器上工作,javascript,php,jquery,ajax,laravel,Javascript,Php,Jquery,Ajax,Laravel,我使用的是Laravel5,并创建了一个简单的ajax请求来启动模型中的函数 $(document).ready(function(){ $('.fa-eye').click(function(){ //we get the data-service value here var serviceID = $(this).data('service'); //every request in laravel requires a token

我使用的是Laravel5,并创建了一个简单的ajax请求来启动模型中的函数

$(document).ready(function(){
    $('.fa-eye').click(function(){
        //we get the data-service value here
        var serviceID = $(this).data('service');

        //every request in laravel requires a token for security, so i set the headers here
        $.ajaxSetup({
            headers: { 'X-CSRF-Token' : $('meta[name=_token]').attr('content') }
        });

        jQuery.ajax({
            //here i am going to my route and adding the serviceID
            url:'/addwatchlist/' + serviceID,
            type: 'GET',//set the request to GET
            success: function( data ){
                console.log(data);
                //this is simply the serviceID that we sent to the controller seen above
                $('.fa-eye').each(function(){
                    if($(this).data('service') == data){
                        $(this).addClass('watchlisted');
                    }
                });
            },
            error: function (xhr, b, c) {
                console.log("xhr=" + xhr + " b=" + b + " c=" + c);
            }
        });
    });
});
好的,这是我的路线

Route::get('/addwatchlist/{id}','WatchlistController@addWatchList');
这是它随后点击的控制器操作:

public function addWatchList($serviceID)
{
    //simply adds it to the database
    WatchList::saveWatchList($this->userid,$serviceID);

    return $serviceID;
    //this sends back the serviceID back to the ajax success method, the same serviceID that was sent here.
}
好的,就是这样,在我的本地主机上,它工作正常,没有问题,现在当我将更改推送到我的开发服务器时,我得到以下错误


有什么想法吗???

看来这与找不到你的类有关
WatchlistController
。为什么?我们说不出来。但我不知道为什么,因为它在我的本地找到了它,并且就是在那里你调用了一个类
HealthWatchInformatics
,它不是WatchlistController的实例,您需要注入它或在构造函数中初始化它。我在我的观察列表控制器的顶部有:使用HealthWatchInformatic\watchlist;因此,我将该类注入到控制器中,
WatchlistController
上有什么名称空间?似乎与此有关,因为无法找到您的类
WatchlistController
。为什么?我们说不出来。但我不知道为什么,因为它在我的本地找到了它,并且就是在那里你调用了一个类
HealthWatchInformatics
,它不是WatchlistController的实例,您需要注入它或在构造函数中初始化它。我在我的观察列表控制器的顶部有:使用HealthWatchInformatic\watchlist;因此,我将该类注入到控制器中,
WatchlistController
上有什么名称空间?