php - How to get Rid of the JSON Error in Firefox -
my response header is
access-control-allow-meth... get, post access-control-allow-orig... * cache-control no-store, no-cache, must-revalidate, post-check=0, pre-check=0 connection keep-alive content-length 81 content-type text/html date mon, 26 aug 2013 06:35:53 gmt expires thu, 19 nov 1981 08:52:00 gmt keep-alive timeout=5, max=99 pragma no-cache server apache/2.4.3 (win32) openssl/1.0.1c php/5.4.7 x-powered-by php/5.4.7`
and request header is
accept application/json, text/javascript, */*; q=0.01 accept-encoding gzip, deflate accept-language en-us,en;q=0.5 cache-control no-cache connection keep-alive content-length 31 content-type application/x-www-form-urlencoded; charset=utf-8 cookie usernameemail=shan%40atlos.com; phpsessid=8asm46iltcqc9oahsbaaap1c16 host localhost pragma no-cache referer http://localhost/test/ user-agent mozilla/5.0 (windows nt 6.1; wow64; rv:23.0) gecko/20100101 firefox/23.0 x-requested-with xmlhttprequest`
i getting error in firefox "not formed" problem in this. getting data correctly in json form show error annoying
java script code make request gettopnotification , uses class make ajax request workspace
your reponse-header incorrect.
if(headers_sent()) die('should not output data before json'); header('content-type: application/json'); echo json_encode($data_for_json); exit;
also, nothing should sent before json, , nothing after either.
in response comment below:
somewhere in php-code you're outputting json. however, stated, reponse header incorrect: content-type
part should set application/json
; above code that. line-by line walktrough:
- checks if did not send , die if did
- set
content-type
part of response header appropriate mime-type - output json (as is, should fine)
- exit;
more update irt comments
you're creating json string manually: can wholeheartedly advice against, use array or object , use json_encode create json. added output_buffering on code, in case.
give try, new code here
update three
in work-space.js replace line
self.responsevalue = self.getvaluefromresponse( jqxhr );
with this
if(type != 'xml') self.responsevalue = data; else self.responsevalue = self.getvaluefromresponse( jqxhr );
save it, clear cache, , try again.
Comments
Post a Comment