admin管理员组文章数量:1307836
Why isn't my method posting data? According to jquery docs: "Request Method
The POST method is used if data is provided as an object; otherwise, GET is assumed."
var car = {{ car }}
var motorcycle = {{ motorcycle }}
$('.send_data').on('click', function(e){
e.preventDefault();
$('#'+container).load(
$(this).attr('href'),
{ car: car, motorcycle: motorcycle },
function(data) {
$('#'+container).effect('highlight');
}
);
})
Why isn't my method posting data? According to jquery docs: "Request Method
The POST method is used if data is provided as an object; otherwise, GET is assumed."
var car = {{ car }}
var motorcycle = {{ motorcycle }}
$('.send_data').on('click', function(e){
e.preventDefault();
$('#'+container).load(
$(this).attr('href'),
{ car: car, motorcycle: motorcycle },
function(data) {
$('#'+container).effect('highlight');
}
);
})
Share
Improve this question
asked May 21, 2014 at 13:34
CapuchinCapuchin
3,7856 gold badges31 silver badges41 bronze badges
3 Answers
Reset to default 7Use $.post() instead of $.load()
The jQuery .load
source code is straightforward:
} else if ( params && typeof params === "object" ) {
type = "POST";
}
Unless car
or motorcycle
are not being classified as objects, a POST
request should have been issued.
Use $.ajax()
and define type: 'post'
.
本文标签: javascriptHow to force jQuery load() method to use POSTStack Overflow
版权声明:本文标题:javascript - How to force jQuery .load() method to use POST - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741835264a2400178.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论