Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

jquery object and string comparison..

Options
  • 09-03-2010 6:40pm
    #1
    Registered Users Posts: 1,127 ✭✭✭


    My god? I think Im going mad? What the hell is wrong with this code?
            log(typeof t); 
            // This is fine, returns 'string', 
            // like a good ickle jquery function
            $.getJSON("/js/json/jsonsource.js",function(js){
                $.each(js.items, function(i, n){
                    if( n.id == b_idx ){
                        $.each(n.pricing, function(y, h){
                            log(typeof t);  
                            // This goes mad?!? Returns 'object'.. 
                            // but I didnt change it? 
                            log(h.id == t); 
                            // This fails, I need to compare the value of t, 
                            // to a parameter here, but it wont let me cos 
                            // they are different datatypes..
                        });
                    }
                });
            });
    

    I've commented the code to show you whats going on.. Firebug spits out "string" for the first typeof, and "object" for the second, but I never cast it?

    Any ideas? By the way, there's nothing wrong with any of the json retrieval, the only thing that fails is the comparison.


Comments

  • Closed Accounts Posts: 2,696 ✭✭✭mark renton


    Dunno - but you should post this in best source code comment

    // This is fine, returns 'string',
    // like a good ickle jquery function


  • Registered Users Posts: 1,127 ✭✭✭smcelhinney


    Oh I have had better..

    Like the
    // Go to bed Stephen, and do this fcuking XMLHttpRequest implementation in the morning
    

    that ended up on a production webserver..


Advertisement