[jQuery] post via AJAX, expecting "script" in return: doesn't work in Safari

[jQuery] post via AJAX, expecting "script" in return: doesn't work in Safari


Hi everyone,
I'm facing a problem with jQuery and AJAX. I am trying to post a form
via AJAX (to a Rails backend), knowing that the returned data type is
"script".
So far, the code I wrote work in Firefox 3.x while in Safari, the form
gets actually posted (and the database update accordingly), while the
UI doesn't receive any update.
Here follows the js code:
$(function() {
    var first_time = true;
    var $d = '';
    $('#product_thumbs').jcarousel({ vertical: true, scroll: 2});
    tb_init('a.thickbox');
    $('#others').flexigrid({ height: 'auto' });
    $('p.no_comments').fadeIn(600);
    $('#comments').fadeOut(0);
    $('#comments').fadeIn(1200);
    $('#product_show_tabs').tabs();
    $('a.add_comment').click(function(){
        $('#new_comment_wrapper').load($(this).attr('href'), function() {
            $('#new_comment').submit(function(){
                $.post($(this).attr("action"), $(this).serialize(), null,
'script');
                $d.dialog('close');
                return false;
            });
            if (first_time == true ){
/*
The following code is a workaround to prevent dialog not showing up
upon subsequent requests. Needs further investigation.
*/
                $d = $('#new_comment').dialog({
                    bgiFrame: true
                    ,modal: true
                    ,draggable: false
                    ,resizable: false
                    ,title: 'Nuovo commento'
                    ,width: 400
                    ,autoOpen: false
                });
                first_time = false;
            }
            $d.dialog('open');
        });
        return false;
    });
});
Of course I'm ensuring that the post is submitted as a javascript
request using:
$.ajaxSetup({
beforeSend: function(xhr){ xhr.setRequestHeader('Accept', 'text/
javascript') }
});
Can you, please, help me?
Thanks in advance.
Regards