当它在crome中运行时,Ajax调用在firefox中不起作用 [英] Ajax call not working in firefox while it works in crome
本文介绍了当它在crome中运行时,Ajax调用在firefox中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我点击一个按钮就打电话给api。问题是代码在crome中按预期工作,而在Firefox中没有。我检查了在firfox的控制台中没有错误。
有趣的是,如果我在浏览器中打开了firefox开发工具,那么请求就会命中控制器,但是,如果我关闭开发人员工具然后发出请求,它就不会触及控制器动作方法
我尝试了什么:
i am calling an api on click of a button. the issue is that the code works as expected in crome while it doesn't in firefox. I checked that there is no error in console in firfox.
Intresting thing is that if i have firefox develper tool opened in the browser then the request is hitting the controller , however if i close the developer tool and then make a request , it's not hitting the controller actionmethod
What I have tried:
<script type="text/javascript">
$(document).ready(function () {
$(document).off('click', '.btnSave').on('click', '.btnSave', function (e) {
$.post("/api/ReturnRequestApi", { ReturnRequestId: $("#Id").val(), ReturnRequestStatusId: $("#ReturnRequestStatusId").val() })
.done(function (data) {
window.location.href = "/Admin/ReturnRequest/List";
});
});
});
</script>
推荐答案
(document).ready(function(){
(document).ready(function () {
(document).off('click','。btnSave')。on('click','。btnSave',function(e){
(document).off('click', '.btnSave').on('click', '.btnSave', function (e) {
.post( / api / ReturnRequestApi,{ReturnRequestId:
.post("/api/ReturnRequestApi", { ReturnRequestId:
这篇关于当它在crome中运行时,Ajax调用在firefox中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文