Query is working when dev (on localhost:8000) but not in production (http://localhost)

Viewed 20

i want to use dynamic SELECT in my laravel project. I use AJAX Query.

Here is my code :

My Controller :

public function showdate(Request $request)
    {    
        $indicateurs = \DB::table('views_indicateurs')->where('date',$request->date)->orderby('bcyber_id')->get();
        return $indicateurs;
    }

My js file :

$(function(){

        $(document).on('change', '#datesel', function(event){
            event.preventDefault();

            var date = $("#datesel").val();
            var _token = $('input[type="hidden"]').attr('value');

            $.ajax({
                method : "POST",
                url : "/indicateurs/visudate/",
                data : {
                    date,
                    _token
                },
                dataType : "JSON",
                
                success : function(data){
                    
                    $("#results").html('');
                    
                    $("#resultsTable").show();

                    for (let index = 0; index < data.length; index++) {
                        $("#results").append('<tr><td>'
                        +data[index].bcyber_nom+'</td><td>'+data[index].nbevt+'</td><td>'
                        +data[index].nbspamfic+'</td><td>'+data[index].nbincid+'</td><td>'
                        +data[index].nbincidnoresp+'</td><td>'+data[index].observations+'</td><td>'
                        +data[index].btrssi+'</td><td>'+data[index].sensib_mois+'</td><td>'
                        +data[index].sensib_3ans+'</td><td>'+data[index].actcybform+'</td><td>'
                        +data[index].equipent+'</td><td>'+data[index].adminent+'</td><td>'
                        +data[index].effectifform+'</td></tr>');
                        
                    }
                },
                
            });


        })

My route :

Route::post('/indicateurs/visudate/', 'IndicateurController@showdate');

When my project works in dev http://localhost:8000 everything work.

When i put it in my www folder nothing happen and with laravel debug i can see this :

The GET method is not supported for this route. Supported methods: POST./var/www/html/indicateursAero/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php#256

and with the firefox inspector console i can see this :

XHRPOSThttp://localhost/indicateurs/visudate/
[HTTP/1.1 301 Moved Permanently 0ms]

XHRGEThttp://localhost/indicateurs/visudate
[HTTP/1.0 405 Method Not Allowed 21ms]

XHRGEThttp://localhost/_debugbar/open?op=get&id=X2867972fb8f19092f9d4c1110099a2e8
[HTTP/1.1 200 OK 13ms]

Thanks for your help

I read a lot of posts, trying to change url, datatype....

0 Answers
Related