I've got a button (link to controler/action) which after clicking calls action validating and generating pdf from php. This function validates i.e. if pdf should generate for this user and if there will be any errors it would not generate certificate but show those errors (of course, if there's no error it will generate certificate and download the file).
I need to do this without reloading the page. And that brings a problem. When I call this function through ajax it gives me the answer with json about any occuring errors, but if there's error it does not generate pdf but ajax gives me PDF as hashed text. I would like to force it to generate pdf and download it to pc.