There is a .php file that returns a .png image file.
How to get this image using jQuery $.ajax() ?
In addition, if there were errors with the input parameters, the .php file will return an error in the JSON path.
How to understand what information was returned - an image or JSON with an error?
UPDATE:
I need to make some statistics graphs using this script. .php file receives some data (for example, account identifier, what statistics is requested) and checks if this user (user identifier obtained from the session is allowed to view the requested user statistics or not). If it is allowed, than the image is returned, if not - than the json error. So what can I do, but if there is an error, the image does not load. But I need to show an error notification to the user.
source share