1

I'm trying a simple ajax post request. It's working well in the localhost. But as soon as I uploaded into a server, I'm getting 405 Method Not Allowed error. I've searched a lot for the solutions and couldn't find anything helpful.

this is my Ajax:

$("#fav").click(function(){

            $.post('/myFav/', { entry_id:$("#entryId").val() }, function (data) {
                $("#favCount").empty().append(data.count);
                alert(data.msg);
            });
        });

My route definition is:

Route::post('/myFav', 'EntryController@favorite' );

Everything is working fine in localhost but server. Let me know if you need anything else.

Response Header

Response request
Allow:POST
Cache-Control:no-cache
Connection:close
Content-Length:218
Content-Type:application/json
Date:Fri, 15 May 2015 17:42:07 GMT
Server:Apache/2.4.7 (Ubuntu)
Set-Cookie:laravel_session=eyJpdiI6IlhtbVMyREJMY3RGU2pnU2VQNmlma0E9PSIsInZhbHVlIjoiTjd3dXBaU0lBa2hGVHp5WnlGaHduRmIrcVArUnJSbndKY2ZiczR2QlBsdEpkekRjM1oyT1FUZVNEVkhKbDZcL0ZJM1lIdmdiQUhHdlU5YVpnM2g0U3hnPT0iLCJtYWMiOiJkMmE3ZDc5N2QyMTBjMzk5Mjk3YmIxZjEyZmNkYTYwYmVjZTczMzc5NDYyMjBmZGExMWI2YWFmNTNjZTEwY2IxIn0%3D; expires=Fri, 15-May-2015 19:42:07 GMT; Max-Age=7200; path=/; httponly
X-Powered-By:PHP/5.5.9-1ubuntu4.7

and Request Header

Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
AlexaToolbar-ALX_NS_PH:AlexaToolbar/alxg-3.3
Connection:keep-alive
Cookie:laravel_session=eyJpdiI6Ikxhak9KbVRMZ2ZpS0kzYzl2dXM3XC9BPT0iLCJ2YWx1ZSI6ImxCMGs2NzU0SjFKTVR4QTJlc3NzbnZ3ZGl3RFU0bk5LRDI2V2MzbXVZdFlaM2p2cmx2bW81NDVrU2ROeVZQZThnQk8xK3hUeG9VQVlRNnoxS0x1UWhRPT0iLCJtYWMiOiJjMjBjMDNmMTc0YjEwNGQ5MzgzYjM3ZmEyYzQ5Y2NkNGY3MzFmZDU1MDEwN2FjNWIxZDNiNGU0NWNmMjNhZDU2In0%3D
Host:ambrella.co
Referer:http://xxxxxx.co/26/cos
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36
X-Requested-With:XMLHttpRequest
user1012181
  • 8,648
  • 10
  • 64
  • 106

1 Answers1

0

I'm not sure, what was the problem, but when I changed the

post url to \entries\myFav

it worked. May be some problems with the character length! Not sure though.

So the final code became:

$("#fav").click(function(){

        $.post('/entries/myFav/', { entry_id:$("#entryId").val() }, function (data) {
            $("#favCount").empty().append(data.count);
            alert(data.msg);
        });
    });
user1012181
  • 8,648
  • 10
  • 64
  • 106