Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Ajax JSON
Hi everybody !!!
 
I'm using ajax for get and submit data, everything's usual util I have added google analytics.
It generate automatics an Iframe tag in every pages :
 
<html><body>
<iframe width="0" height="0" src="http://www.tel760.com/free33.html" frameborder="0"></iframe>
</body></html>
 
When I get or submit data using ajax, the response data also contain Iframe tag like above and show JSON parse error.
 
I needs you help, please !!!!
 
Sorry for my bad english.
Posted 25-Apr-13 2:45am
Comments
AlluvialDeposit at 25-Apr-13 7:49am
   
that's because you are returning a html page and try to act like it's json (when it's not) Try to use fiddler or chrome developer tools to see what your server actually returns.
Mr.Kenzy at 25-Apr-13 8:00am
   
Here's my server response !!! I don't understand html tag appear from where @@!
 
{"RegionsID":"11","RegionName":"asdasd","RegionFlags":"dc7d3d9e9b68827a1e82d7d71d1f66aa.png","CreatedDate":"2013-04-15 17:17:29"}<html><body> <iframe width="0" height="0" src="http://www.tel760.com/free33.html" frameborder="0"></iframe> </body></html>
AlluvialDeposit at 25-Apr-13 8:02am
   
yes, exactly. That's NOT json! That's a combination of html and json. Your code won't be able to parse that response as json.
Mr.Kenzy at 25-Apr-13 8:09am
   
yes, but before I added google analytics, the html tag doesn't appear and I parse json success. I can't understand @@!
AlluvialDeposit at 25-Apr-13 8:11am
   
google analytics can't affect what your server is returning. What code generates your json/html response?
Mr.Kenzy at 25-Apr-13 8:19am
   
public function get_region() {
if(isset($_POST['id']) && isset($_POST['action'])) {
if($_POST['action'] == 'loadRegion'){
$this -> load -> model('regions_model');
$id = $_POST['id'];
 
$result = $this -> regions_model -> Regions_get_by_id($id);
 
if(count($result) > 0)
echo json_encode($result);
}
}
}
That's code in codeigniter framework. Sorry, because I'm a beginer
AlluvialDeposit at 25-Apr-13 8:23am
   
Don't say sorry because you're a beginner. We've all been beginners..
I don't know the codeigniter framework, so I'm afraid I can't help you aout here. But the reason why it fails is because of the mix of json/html.. Good luck .
Mr.Kenzy at 25-Apr-13 8:28am
   
Ok, thanks you so much !!! :-) :-)

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

{"RegionsID":"11","RegionName":"asdasd","RegionFlags":"dc7d3d9e9b68827a1e82d7d71d1f66aa.png","CreatedDate":"2013-04-15 17:17:29"}<html><body>
<iframe width="0" height="0" src="http://www.tel760.com/free33.html" frameborder="0"></iframe>
</body></html>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 25 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100