laravel ajax call in safari and on mobile methodNotFoundHttpException

95 Views Asked by At

I'm having some issues on my application, I'm using laravel 4.2 framework. Everything seems to be working fine, except when I test it on safari and mobile phone

This is the ajax request that I make

function couponAuth(data)
    {
        $.ajax({ 
            type: 'POST',
            url: 'coupon/verify',
            data: data,
            success: function(response){
                if(response.status === 'fail')
                {
                    displayError(response.data.coupon[0]);
                }
                else{
                    $(location).attr('href',response.data.url);
                }
            },
            error: function(response){

        }
    });
}

this is the route

Route::group(array('before' => 'csrf'), function(){
    Route::post('/coupon/verify',['uses' => 'AccessController@validate', 'as' => 'coupon-verify']);
});

1

There are 1 best solutions below

0
On

try this

function couponAuth(data)
    {
        $(document).ready(function(){
            $.ajax({ 
                type: 'POST',
                url: 'coupon/verify',
                data: data,
                success: function(response){
                    if(response.status === 'fail')
                    {
                        displayError(response.data.coupon[0]);
                    }
                    else{
                        $(location).attr('href',response.data.url);
                    }
                },
                error: function(response){
                }
            });
        });
    }