Welcome to WebmasterWorld Guest from 54.226.25.231

Forum Moderators: open

Message Too Old, No Replies

problem with ajax returning html garbage along with json string.

     

nelsonm

11:18 pm on Dec 16, 2013 (gmt 0)

5+ Year Member



hi,

For some reason, I'm getting a chuck of html preceding the json string being returned after an ajax call to a php script.

I verified the encoded associative array in the php script is correct. But when it's received by the $.ajax() method, i get a "JSON.parse: unexpected character" error message thrown from the ajaxConvert function in the jQuery-2.0.3.js library script.

The response tab for the php script POST line in Firebug's Console tab shows the html preceding the json string.

I have no clue as to how the html is getting included in the json response string.

I'm running WAMP server on a windows 7 pc acting as a development server and work off a windows 7 workstation in my home office.

Does anyone have a clue as to why this is happening?

thanks.

daveVk

1:25 am on Dec 19, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



The response tab for the php script POST line in Firebug's Console tab shows the html preceding the json string


Search for a snippet of this HTML ( include something destintive like class name ) within your PHP file(s), seems likely to be server issue.

nelsonm

1:40 am on Dec 19, 2013 (gmt 0)

5+ Year Member



I have no HTML in any of the PHP scripts.

But I will search for this HTML within the server root.

nelsonm

5:34 am on Dec 20, 2013 (gmt 0)

5+ Year Member



ok, i figured it out!

The html is actually a php error message. If there is a syntax or other error in your php script, the error message will output (echoed) as html if error handling is not setup properly in the php script.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month