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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

jquery object and string comparison..

  • 09-03-2010 5:40pm
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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