I’m trying to check the value returned from $.ajax is a string ‘ERROR’, that I’ve echoed back from PHP.
if (this.data === "ERROR");
{
return { 'bla' : 'bla' };
}
But it will trigger the if every time.. also with ==
I tried:
if (typeof(this.data) == 'string')
Seems to work, but still have the problem of returning an object when it’s ‘undefined’, tried:
typeof(this.data) === 'string' || this.data=== 'undefined'
Tried all kinds of combinations, but simply said, what I want to do,
When there is not nicely formatted JSON, but only ‘ERROR’, then I want to give in my own default JSON object and continue, but for some reason the if statement will be true every time.
There must be a simpler way for this.
And I can’t work with the error: or succes: ‘classes’ of $.ajax, because It’s a custom error message I return.
You’ve got an extra semicolon:
Remove it.