Skip to content
Advertisement

Unexpected end of JSON input ajax

Here is what is going on. I have an error in my Ajax code that is causing the following error:

Unexpected end of JSON input ajax

Here is my code:

I’m getting data from an array by doing the following:

JavaScript

Then I’m parsing the JSON by doing the following:

JavaScript

Based on the code, what could be causing the issue?

Thank you, Kevin Davis

Advertisement

Answer

Number 1 echo json_encode($departTickets); your encoding the data in json.

Then parsing it to AJAX, but you have not told ajax that your dataType is in json.

So we tell ajax like this

JavaScript

Please note how i changed the position of url and placed the dataType bellow it.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement