homepage Welcome to WebmasterWorld Guest from 54.196.24.103
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
problem with ajax returning html garbage along with json string.
nelsonm




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

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




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

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




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

I have no HTML in any of the PHP scripts.

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

nelsonm




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved