JQuery will not set a higher scoped object in callback

Posted by user344666 on Stack Overflow See other posts from Stack Overflow or by user344666
Published on 2010-05-19T02:30:00Z Indexed on 2010/05/19 2:30 UTC
Read the original article Hit count: 223

Filed under:
|
|

Hello, I have a jquery callback function. In that function I want it to change the value of a varible that is in a higher scope, for somereason it is not doing that. Here is the code.

Thanks

function add() {
var returnedData = {
                my_id: 0
        };
        $.post("add_event.php", { event : toSendText }, function(data) {returnedData.my_id = 5;}, "json");
        if(add_page == true){
                alert(returnedData.my_id);
                window.open('content-list.php?cal_id=');
        }
}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery