itwhiz Posted June 26, 2019 Share Posted June 26, 2019 Hope this is the correct place for this question. Developed a system on my Laptop (Win10 WAMP server connecting to SQL Server etc) working fine for all the XMLHTTPRequests', but when I put the same code on the main server (Linux, Using LAMP and connecting to SQL Server ) I get the following error from the XMLHTTPRequests "VM49:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0". Clicking on the VM49:1 I can see the returned value from the JSON.parse and it has the correct values, but also contains <!-- --> at the beginning just as though there should be a comment in there. Any ideas on how to get rid of this error ??? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 26, 2019 Share Posted June 26, 2019 Get rid of the invalid JSON text, that shouldn't be there. Link to comment Share on other sites More sharing options...
ishan_shah Posted March 23, 2020 Share Posted March 23, 2020 The error is within your server side, when there's an error on your server side, the response comes with html tags '<' when there's an error php will add tag with the error message. Therefore your json contains the html tags and becomes invalid because of unexpected tags. if you have an array with semi colon, at last value description please remove that and try again for example : if you have array like this: $eventstArray[] = array ( 'label' => $eventsQuery2['eventTitle']; 'venue' => $eventsQuery2['venueName']; 'category' => $eventsQuery2['catDesc']; 'price' => $eventsQuery2['eventPrice']; 'description' => $eventsQuery2['eventDescription']; ); it should be like this: $eventstArray[] = array( 'label' => $eventsQuery2['eventTitle'], 'venue' => $eventsQuery2['venueName'], 'category' => $eventsQuery2['catDesc'], 'price' => $eventsQuery2['eventPrice'], 'description' => $eventsQuery2['eventDescription'] ); just remove last semi-colon Link to comment Share on other sites More sharing options...
Ingolme Posted March 23, 2020 Share Posted March 23, 2020 Please do not reply to old topics. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now