服务器上某些Ajax请求的错误500

时间:2018-12-10 16:20:48

标签: javascript php ajax laravel

某些Ajax调用(发布并获取)时出现500错误。我只在我的产品(ubuntu服务器)中获得这些,而不是本地(xampp)。为请求发送CSRF令牌。有人知道我能做什么吗?

有效的请求

$.ajax({
        type: 'get',
        url:getHerstellerUri,
        success:function(data){ 
            $.each(data,function(j,value){
                var option =$("<option>",
                            {text : value.hersteller})
                $('#hersteller1').append(option);    
            })
    })

这里是无效的:

$.ajax({
                type: 'post',
                url:readHerstellerUri,
                dataType: "json",
                data:{'title':herstellerAuswahl},
                success:function(data){
....

我对这些ajax调用的web.php是:

Route::get('/getHersteller', 'HerstellerController@getHersteller')->name('getHersteller');


Route::post('/readHersteller', 'BikeController@readHersteller')->name('readHersteller');

和.htaccess与本地版本不同:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle http -> https redirect
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ /index.php [L]
</IfModule>

2 个答案:

答案 0 :(得分:0)

500状态代码是服务器错误。因此请更正您的服务器端脚本

答案 1 :(得分:0)

这是我的控制器(laravel)的问题。某些路由不适用于所有控制器。我不知道为什么,但是如果将请求的功能放到另一个控制器上,它将起作用。

相关问题