我有一个奇怪的情况,我使用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);
Run Code Online (Sandbox Code Playgroud)
头:
Request URL:http://mydomain/leads/action
Request Method:GET
Status Code:200 OK
Run Code Online (Sandbox Code Playgroud)
我也加入了Provisional headers are shownChrome.
脚本应该POST到url并将数据加载到模态中.以下是我在本地服务器上时发送的标头:
ajax:true
lead:4273
type:reminder
Run Code Online (Sandbox Code Playgroud)
任何指针将不胜感激
这是一个重定向问题:当您POST向leads/action/服务器发送请求时,会将其重定向到leads/action请求GET。您可以通过删除尾部斜杠来解决此问题:
$modal.load('leads/action', _post, function(){
//^ Here
});
Run Code Online (Sandbox Code Playgroud)
我希望这能帮到您。