我有一个奇怪的情况,我使用jQuery load()将一些内容加载到一个模态中。这在开发中完美地工作,但在生产服务器上,该对象被忽略并且仅发送GET请求。我检查了成功的typeof
对象,并尝试了load方法的第二个参数中的其他变体。从来没有过这个。
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);
接头:
Request URL:http://mydomain/leads/action
Request Method:GET
Status Code:200 OK
我也在Chrome中获得Provisional headers are shown
。
脚本应该POST
到url并将数据加载到模态中。下面是我在本地服务器上时发送的标题:
ajax:true
lead:4273
type:reminder
任何指针都将不胜感激
答案 0 :(得分:4)
这是一个重定向问题:当您POST
向leads/action/
发出请求时,您的服务器会将leads/action
请求重定向到GET
。您可以通过删除尾部斜杠来解决此问题:
$modal.load('leads/action', _post, function(){
//^ Here
});
我希望这会对你有所帮助。