tsoteen89 / cochlearProject

Website development for Cochlear
1 stars 0 forks source link

console errors with "data" variables returned from async calls #350

Open rugbyprof opened 9 years ago

rugbyprof commented 9 years ago

What is the deal with all the console errors?

if(typeof data != "undefined"){
    //blah
}

But a "string" is NOT undefined, and said "string" does not have methods like records.length.

So come up with a standard value to return and test for or brute force the testing within the callback:

if(typeof data != "undefined" ){
    if(typeof data == "object"){
        //use records.length or whatever else is supposed to be in the object
    }else{
        //It's defined, but its NOT an object so ...
        //I'm guessing its a string?? So now what?
    }
}

CLEAN UP THE CONSOLE ERRORS......

rugbyprof commented 9 years ago

I fixed the ones that were erroring on me. But there are still a lot of code blocks that are using data assuming it's defined. At the top of aiiController I see testing to ensure that data is an "object". Why did you guys stop?

rugbyprof commented 9 years ago

I haven't pushed my changes yet. I will here in a bit.