I have an AJAX request in my page and the .php page echoes an integer or string based on the event in the page. But, when the variable reaches to my actual javascript file , it becomes string. For example 4 changes to "4". And that is making my program problematic because my program has to run according to the responseText. I have a XMLHTTPRequestObject.onload function that works like:
if(typeof XMLHTTPRequest.responseText === "number"){
// do something
}
My php script provides a result either integer or string and if the result is string, then I can perform the function but it is not happening like so. I tried changing the variable using parseInt()
and Number()
but then, everything gets changed to number either it was s string. So, how do I tackle this problem? Please do help!