I have database web pages, analyt.php and index.php. Analysis.php receives data from the database, sorts it according to the required template, and then echoes json_encode($array); in a div with credentials. I am trying to get JSON data and parse it on the index.php page.
However, I am getting an error. SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
I try to get this data every time the user selects a parameter from the selection window.
My jQuery code:
$(document.body).on('change', '.select' , function () { var identification = $(this).val(); var JSONText = $(this).closest('div[id|="module"]').find('p[id="JSON"]'); JSONText.load('analysis.php?data=' + identification + ' #data'); console.log("JSON Imported: '" + identification + "'"); var obj = jQuery.parseJSON(JSONText.text()); console.log(JSONText.text()); });
EDIT: As you can see, I have a console.log(JSON.text()); fragment console.log(JSON.text()); . The JSON result that I get is correct. The only problem that I think may be that quotation marks are all " instead of JSON quotes other than external quotes.
source share