简体   繁体   English

jQuery的帖子在IE中不起作用

[英]jquery post doesn't work in ie

My jquery code works in ff, chrome, opera, safari but it doesn't work in ie. 我的jQuery代码可以在ff,chrome,opera,safari中使用,但在ie中不起作用。 My data i am reciving is in html format. 我正在接收的数据是html格式。 What I have to change? 我必须改变什么?

$("input[type='radio'][name='dishType']").change( function() {
    var dishType = $(this).val();
    $.post('index.py/ingredients', { 'q' : dishType}, function(data) { $('.ingredients').html(data)});
});

The "change" event will only fire in IE if you click somewhere outside of radiobutton. 如果您单击单选按钮之外的某个位置,则“更改”事件将仅在IE中触发。 To fix this you should also listen for "click" events. 要解决此问题,您还应该侦听“ click”事件。

It might not actually be the AJAX call. 它实际上可能不是AJAX调用。

Have you checked for any trailing , or other syntax errors (try jslint) IE is very strict on the syntax and it maybe that which is the issue rather than the actual AJAX call it's self. 你有没有检查是否有尾随,或其他语法错误(尝试JSLint的),即是对语法非常严格,它也许这也就是问题,而不是实际的AJAX调用它的自我。

Having said that it could just be that IE won't fire a 'change' event on simply changing the value of a radio button, it waits for it to lose focus (blur). 话虽这么说,IE可能不会仅更改单选按钮的值就不会触发“更改”事件,而是等待它失去焦点(模糊)。 See quirksmode documentation on the change event . 有关更改事件,请参阅quirksmode文档。 Seem to remember the work around is to listen to click instead of 'change'. 似乎要记住的变通方法是听点击而不是“更改”。

can you try removing the quotes out of the q. 您可以尝试从q中删除引号吗? You dont need to add it.. IE might be messing that up.. not sure.. but something worth trying.. 您不需要添加它。.IE可能把它弄乱了..不知道..但是值得一试。

And can you try alerting in the callback function to see if you are actually getting a response. 您是否可以尝试在回调函数中发出警报,以查看是否真正得到响应。

hope that helps 希望能有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM