"fn_Get_File" Function In "change_Order_Status" Function

When I try to use "fn_get_file" function in "change_order_status" function I get Error:

Oops, something went wrong (SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data). Please try again.

Why I am getting this? What should I do?

When I try to use "fn_get_file" function in "change_order_status" function I get Error:

Oops, something went wrong (SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data). Please try again.

Why I am getting this? What should I do?

Hello!

AJAX request expects for the request to return JSON encoded data, however the fn_get_file function returns file's content, so it firstly clears the buffer output, causing the AJAX to execute its class destructor from the callback function passed to the ob_start in the AJAX constructor. So the process gets terminated even before the file is being returned in the request.

In this case it's better to make non-AJAX request to the separate controller where you will output the content of the required file.

I hope it will help you.