I'm trying to access the returned value and add a check of .contains
so I can know if I need to reload the page or not. I've been trying to do something like the following:
alert(msg.d);
if(msg.d.contains("deleted"))
location.reload();
The returned object is a string.
It does show me the alert message, but won't reload the page once it's necessary. Did I do something wrong?
There is no .contians()
method, You need to use String.prototype.indexOf()
The
indexOf()
method returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex. Returns -1 if the value is not found.
Code
if(msg.d.indexOf("deleted") > -1)
location.reload();