Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery load ignoring object and not posting

I have a strange situation where I am loading some content into a modal using jQuery load(). This is working perfectly in development but on the production server, the object is being ignored and only sending a GET request. I've checked the typeof object which is successful and tried other variations in the second parameter of the load method. Never had this before.

var $modal = $('#ajax-modal');


        $('body').modalmanager('loading');

        //_token = document.querySelector('meta[name="csrf-token"]').getAttribute('content');

        setTimeout(function(){

            var _post = {ajax:true, lead:lead, type:type };

            $modal.load('leads/action/', _post, function(){


          });
        }, 1000);

Headers:

Request URL:http://mydomain/leads/action
Request Method:GET
Status Code:200 OK

I'm also getting Provisional headers are shown in Chrome.

The script should POST to the url and load the data into the modal. Below are the headers sent when I'm on my local server:

ajax:true
lead:4273
type:reminder

Any pointers would be appreciated

like image 787
jhodgson4 Avatar asked Jun 15 '16 08:06

jhodgson4


1 Answers

It's a Redirection problem: When you POST your request to leads/action/ your server redirects it to leads/action with a GET request. You can resolve this by removing the trailing slash:

$modal.load('leads/action', _post, function(){
                       //^ Here

});

I hope this will help you.

like image 141
Ismail RBOUH Avatar answered Nov 14 '22 20:11

Ismail RBOUH