Unknown character set to javascript via PHP

Hello Everybody,

Please see picture first to get a visual perspective of the problem. As you can see something is passed along the PHP script, circled in red. what ever is within the circle is causing issues with my code but I can not seem to isolate where the circle value is coming from.

I have the relevant parts of the codes below.
Any help would be greatly appreciated.

image

Javascript code. Only copy/pasted the relevant part of the code to keep this short.

    if(xhr.readyState === 4 && xhr.status === 200) {
          if(xhr.responseText === 'found') {                   
                console.log("Found - Data saved!!!" + xhr.responseText);
           } else { 
               console.log("failed to save data =>: " + xhr.responseText);
                } 
            }

PHP code. The code works. Only copy/pasted the relevant part of the code to keep this short. This code sends the “found” or "not found to the javascript.

        $result = $query->fetch(PDO::FETCH_ASSOC);
        if(!$result) {
          echo json_encode('not found');
        } else {
          echo json_encode('found');
        }
    }
  }
?>

That first screen shot implies there’s another echo somewhere before the lines of code you’re posting, so you’re getting a blank line, then the found/not found.

How are you handling it if this condition is false?

After posting this message I took a look at the files i included and sure enough the include files were the ones adding the space.
Thanks for you reply, greatly appreciated the help.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.