Javascript ajax调用中的交叉浏览问题

Javascript ajax调用中的交叉浏览问题,javascript,jquery,ajax,Javascript,Jquery,Ajax,当我在firefox mozila中执行该代码时,该代码运行良好(对于注册用户),但当我们在IE(iternet explorer 8)中尝试该代码时,会发出警报(“抱歉,您必须先登录”);此消息正在发送。(在这两种情况下均为注册或gest) 另一件事:对于gest,从服务器返回数据的用户为null。表示d=null 另一件事是,当以gest用户身份在firefox mozila中执行时,什么也没有发生意味着警告(“对不起,你必须先登录”);此消息未提交 我该怎么办 function manag

当我在firefox mozila中执行该代码时,该代码运行良好(对于注册用户),但当我们在IE(iternet explorer 8)中尝试该代码时,会发出警报(“抱歉,您必须先登录”);此消息正在发送。(在这两种情况下均为注册或gest)

另一件事:对于gest,从服务器返回数据的用户为null。表示d=null

另一件事是,当以gest用户身份在firefox mozila中执行时,什么也没有发生意味着警告(“对不起,你必须先登录”);此消息未提交

我该怎么办

function manageVoting() {
        var parameter;
        var myVoting;
        var divVoting;
        var divVotes;
        var value = -1;
        var parameterData;
        $('div.votemaincontainer').each(function() {
            parameter = $(this).find('#[id$= hfUrl]').val();
            myVoting = parseInt($(this).find('#[id$=hfMyVote]').val());
            divVoting = $(this).find('[id$=divVoting]');
            divVotes = $(this).find('[id$=divVotes]');

            function processVote(value) {
                if (value == 0 || value == 1) {
                    parameterData = parameter + value + "'}";

                    $.ajax({
                        type: 'POST',
                        url: 'UserControls/Vote/VoteAction.aspx/Voting',
                        data: parameterData,
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function(data) {
                            var result = eval(data.d);

                            if (result) {
                                if (result.length > 1) {
                                    if (result[1] == 1 && result[2] == 1) {
                                        $('img.voteupImage').attr('src', 'UserControls/Vote/Images/aftervote_arrow_up.png');
                                        $('img.votedownImage').attr('src', 'UserControls/Vote/Images/arrow_down.png');
                                        $('div.divVotes').html(result[0]);
                                        $(myVoting).val(value);
                                    }
                                    else if (result[1] == 0 && result[2] == 1) {
                                        $('img.voteupImage').attr('src', 'UserControls/Vote/Images/Arrow Up.png');
                                        $('img.votedownImage').attr('src', 'UserControls/Vote/Images/aftervote_down.png');
                                        $('div.divVotes').html(result[0]);
                                        $(myVoting).val(value);
                                    }
                                    else if (result[2] < 0 && value == 0) {
                                        alert('U HAVE ALL READY VOTED DOWN');
                                    }
                                    else {
                                        alert('U HAVE ALL READY VOTED UP');
                                    }
                                    $('#[id$=hfMyVote]').html(result[1]);
                                }
                                else {
                                    alert('I AM ENSIDE ELSE');
                                    //$('div.divVotes').html(result[0] - 1);
                                    alertDialog("Rating any knowledge item is only available for Registered User.<br>Do you want to <a class='signUpPopUp' href='signup.aspx'> signup</a> Now?");
                                }

                            }
                        },
                        error: function() {
                            alert("sorry u must have to login first");

                        }
                    });
                }
            }

            $('img.voteupImage').live('click', function() {

                value = 1;
                processVote(value);

            });
            $('img.votedownImage').live('click', function() {

                value = 0;
                processVote(value);

            });
        });
    }

    $(function() {
        manageVoting();
    });
函数manageVoting(){
var参数;
var-myVoting;
无风险投票;
投票权;
var值=-1;
var参数数据;
$('div.votemaincontainer')。每个(函数(){
参数=$(this.find('#[id$=hfUrl]').val();
myVoting=parseInt($(this).find('#[id$=hfMyVote]').val();
divVoting=$(this.find(“[id$=divVoting]”);
divvoates=$(this.find(“[id$=divvoates]”);
函数processVote(值){
如果(值==0 | |值==1){
parameterData=参数+值+“'}”;
$.ajax({
键入:“POST”,
url:'UserControls/Vote/VoteAction.aspx/Voting',
数据:参数数据,
contentType:“应用程序/json;字符集=utf-8”,
数据类型:“json”,
成功:功能(数据){
var结果=评估(数据d);
如果(结果){
如果(result.length>1){
if(结果[1]==1&&result[2]==1){
$('img.voteupImage').attr('src','UserControls/Vote/Images/aftervote_arrow_up.png');
$('img.votedownImage').attr('src','UserControls/Vote/Images/arrow_down.png');
$('div.divvoces').html(结果[0]);
$(myVoting).val(值);
}
else if(结果[1]==0&&result[2]==1){
$('img.voteupImage').attr('src','UserControls/Vote/Images/Arrow-Up.png');
$('img.votedownImage').attr('src','UserControls/Vote/Images/aftervote_down.png');
$('div.divvoces').html(结果[0]);
$(myVoting).val(值);
}
else if(结果[2]<0&&value==0){
警惕(“你已经准备好投票否决”);
}
否则{
警惕(“你已经准备好投票了”);
}
$('#[id$=hfMyVote]').html(结果[1]);
}
否则{
警惕(“我是恩塞德·埃尔斯”);
//$('div.divvoates').html(结果[0]-1);
alertDialog(“对任何知识项进行评级仅对注册用户可用。
您现在要吗?”); } } }, 错误:函数(){ 警报(“抱歉,您必须先登录”); } }); } } $('img.voteupImage').live('click',function()){ 数值=1; 过程投票(价值); }); $('img.votedownImage').live('click',function()){ 数值=0; 过程投票(价值); }); }); } $(函数(){ 管理投票(); });
ajax调用成功与否并不取决于正在验证的用户。如果用户未通过身份验证,http服务器应返回403代码,如果一切正常,则返回200代码

success(data, textStatus, XMLHttpRequest){
    if (XMLHttpRequest.status == 403){
        alert("sorry u must have to login first");
        return;
    }
}