jQuery和IE提交,当作ajaxForm不工作 [英] jquery and IE submit, ajaxForm not working

查看:178
本文介绍了jQuery和IE提交,当作ajaxForm不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格:

<form method="post" action="/balda/server.wsgi" id="gameboard" name="gameboard" >

一个提交按钮:

with a submit button:

<input type="submit" name="submit" value="Поиск" style="" onmouseover="CheckElements();">

提交按钮应该发送AJAX绑定过程:

the submit button should send ajax bind process:

jQuery(document).ready(function(){
    jQuery('#gameboard').submit( function() {
        $.ajax({
            url     : $(this).attr('action'),
            type    : $(this).attr('method'),
            dataType: 'json',
            data    : $(this).serialize(),
            success : function( data ) {
                       onAjaxSuccess( data );
                    }
        });
        return false;
    });
});

有接受功能:

function onAjaxSuccess (result)

这一切工作正常,在镀铬,FF,歌剧,Safari浏览器,但它不能在Internet Explorer 9中工作(别人没有尝试过)

All this works fine in chrome, ff, opera, safari, but it does not work in Internet Explorer 9 (others not tried it)

在IE9中,结果变量是空的。 我尝试另一个绑定提交按钮是这样的:

In IE9, the result variable is empty. I tried another bind submit button like this:

$('document').ready(function( result )
{
    $('#gameboard').ajaxForm( {    
        type: "POST",
        data    : $(this).serialize(),
        success: onAjaxSuccess,
        dataType: 'json',
        error: function(){ alert ( 'Error loading data format.' ); }
    }); 
});

但结果是一样的FF铬野生动物园歌剧作品,除了IE9。

But the result is the same ff chrome safari opera work, except for IE9 .

请告诉我可能是什么问题。

Please tell me what could be the problem.

推荐答案

问题在于IE9不理解的JSON的在编码CP1251的格式,即使它在响应头明确说明。在UTF-8 JSON响应的翻译解决了这个问题,IE9。

The problem was that IE9 does not understand the format of "JSON" in the encoding cp1251, even though it is clearly stated in the response header. Translation of the JSON response in utf-8 solved the problem with IE9.

这篇关于jQuery和IE提交,当作ajaxForm不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆