jQuery:在Safari中ajax调用成功为空后返回数据

时间:2022-10-08 08:24:10

This is the jQuery code I'm trying to run. It works perfectly on all browsers except on Safari it returns an empty string. Any idea ?

这是我正在尝试运行的jQuery代码。它适用于所有浏览器,除了在Safari上它返回一个空字符串。任何想法 ?

$(".voteup").click(function()   {
    var id = $(this).attr("id");
    var name = $(this).attr("name");
    var dataString = 'id='+ id ;
    var parent = $(this);

    var fbid = $(".clientname").attr("id");
    var dataString2 = 'fbid='+ fbid ;


    if(name=='up'){

        $(this).fadeIn(200);            
        $.ajax({
            type: "POST",
            url: "up_vote_fb.php",
            data: dataString,
            cache: false,
            success: function(data){
                $('#project-vote' + id).html(data);
                $.ajax({
                    type: "POST",
                    url: "get_clientpoints.php",
                    data: dataString2,
                    cache: false,
                    success: function(data){
                        $('#clientpoints').html(data);
                    }  
                });
            }           
        });


    } 
    return false;
});

Here's the code that is being returned :

这是返回的代码:

echo "<b>".$up_value."</b> VOTES";  

2 个解决方案

#1


0  

Michel,

Try adding the dataType field to you ajax call like:

尝试将dataType字段添加到ajax调用,如:

   $.ajax({
        type: "POST",
        url: "up_vote_fb.php",
        data: dataString,
        dataType: "text",
        cache: false,
        success: function(data){
            $('#project-vote' + id).html(data);
            $.ajax({
                type: "POST",
                url: "get_clientpoints.php",
                data: dataString2,
                dataType: "text",
                cache: false,
                success: function(data){
                    $('#clientpoints').html(data);
                }  
            });
        }           
    });

#2


0  

It looks like someone had a similar problem and it is a bug with the Safari.

看起来有人有类似的问题,这是Safari的一个错误。

Check this out and see if it helps make sense: http://forums.iis.net/post/1999417.aspx

检查一下,看看它是否有意义:http://forums.iis.net/post/1999417.aspx

#1


0  

Michel,

Try adding the dataType field to you ajax call like:

尝试将dataType字段添加到ajax调用,如:

   $.ajax({
        type: "POST",
        url: "up_vote_fb.php",
        data: dataString,
        dataType: "text",
        cache: false,
        success: function(data){
            $('#project-vote' + id).html(data);
            $.ajax({
                type: "POST",
                url: "get_clientpoints.php",
                data: dataString2,
                dataType: "text",
                cache: false,
                success: function(data){
                    $('#clientpoints').html(data);
                }  
            });
        }           
    });

#2


0  

It looks like someone had a similar problem and it is a bug with the Safari.

看起来有人有类似的问题,这是Safari的一个错误。

Check this out and see if it helps make sense: http://forums.iis.net/post/1999417.aspx

检查一下,看看它是否有意义:http://forums.iis.net/post/1999417.aspx