Solved

Ajax not working in IE7, works in IE8 and firefox

Posted on 2011-03-12
10
1,129 Views
Last Modified: 2012-05-11
Experts,
I added an Ajax script to my website.
http://www.viewpts.com/sports3.php

When viewed in IE8 or Firefox, clicking the Thumbs up or Thumbs Down icons will result in the user casting a vote instantly via ajax.  This works correctly.

When I do this in IE7, the vote gets cast but only after the page refreshing.
I also notice a Javascript Error in IE7 but I can't pinpoint exactly what it is.
I'm not sure if the issue is related.

I've also read this article on Experts Exchange, but I'm unsure of which variables I would change in my code:
http://www.experts-exchange.com/Programming/Languages/Scripting/AJAX/A_3565-Ajax-and-IE7-problems.html?sfQueryTermInfo=1+10+30+ajax+ie7+ie8+work

Any ideas?

Thanks,
-dsg
<?php
session_start();

include_once("/home/allgo5/public_html/viewpts/functions.php");
include_once("/home/allgo5/public_html/viewpts/thumbsup/init.php");
include_once("/home/allgo5/public_html/viewpts/db.php");

dbConnect('allgo5_viewpts');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<?
echo ThumbsUp::css();
echo ThumbsUp::javascript();

?>
<title>View Points</title>
<meta http-equiv=Content-Type content=application/xhtml+xml; charset=UTF-83 />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="layout.css" rel="stylesheet" type="text/css" />

</head>
  	<?

    $sz = "Select * From SportsStories where ViewPointQuestion IS NOT NULL order by PostDate desc LIMIT 12";  
	$rz=mysql_query($sz) or die(mysql_error());
		while($az=mysql_fetch_array($rz))
		{
     	$th_id = "SportsID" . $az[NewsID];	
		echo "<li><span><b><TABLE width='420'><TR><TD><A HREF='" . $az[Link] . "'Target=Blank>"  . $az[Title] . "</A></TD></TR><TR><TD>" . $az[ArticleDate] . "</TD></TR><TR><TD width=360'></b><STRONG>" . $az[ViewPointQuestion] . "</STRONG></TD><TR><TD>";
		
//		if ($me) {
		
		echo ThumbsUp::item($th_id)->template('thumbs_up_down');
		
//		}
//		else
//		{
//		echo "<P><I>Login to vote on this question/story!</I>";	
//		}
		
		echo "</TD></TR><TR><TD>";
		?>
      <iframe src="http://www.facebook.com/plugins/comments.php?href=viewpts.com/article.php?id=<?=$az[NewsID]?>&linkTarget=blank&permalink=1" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:130px; height:16px;" allowTransparency="true"></iframe> 

        <?
		echo "<p></TD></TR></TABLE></span></li>";
		echo "<HR>";
		}
	?>
</body>
</html>

Open in new window

0
Comment
Question by:dsg138
  • 4
  • 4
  • 2
10 Comments
 
LVL 29

Expert Comment

by:Badotz
ID: 35116337
>>I also notice a Javascript Error in IE7 but I can't pinpoint exactly what it is.

hmmm...that might be important? How do you know an error has occurred? Can you tell us anything about the error?
0
 

Author Comment

by:dsg138
ID: 35116375
In the left corner of the brower, I get the Yellow warning icon.
Line: 2
Char: 715
Error:  Expected Identifier, String or Number
Code: 0
0
 
LVL 29

Expert Comment

by:Badotz
ID: 35116388
Can you show us lines 1 through 10?
0
 

Author Comment

by:dsg138
ID: 35116903
All of the code in this page is posted above.  Thanks!
0
 
LVL 29

Expert Comment

by:Badotz
ID: 35116968
Then please, show us the 715th character of line 2.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:dsg138
ID: 35116982
I can't.  Line 2 is session_start().  And there isn't 715 characters.
I don't know how to troubleshoot this. That's why I'm posting here.  This message doesn't make sense to me.

Again, the function works but refreshes the page instead of letting Ajax doing the update.
Only an issue in IE7.
0
 
LVL 29

Expert Comment

by:Badotz
ID: 35117141
What is line 2 from the first JavaScript file in your page?
0
 
LVL 12

Accepted Solution

by:
zappafan2k2 earned 500 total points
ID: 35119194
In the file init.min.js.php
near the code
spinner_large_red.gif" />',};switch(template)

Open in new window

You have a comma followed by a brace:
,}

Open in new window

Try getting rid of the comma.  If that doesn't fix it, then you'll probably have to un-minify your code to see what's really going on.
0
 

Author Closing Comment

by:dsg138
ID: 35121736
Perfect!  This fixed both the Javascript issue and the Ajax issue.

I can't believe it was ONE COMMA!

Many thanks!

-dsg
0
 
LVL 12

Expert Comment

by:zappafan2k2
ID: 35121752
When I was in college, my teacher told me that a person was almost killed by a medical device because of a misplaced semicolon.  

Anyway, glad to hear it's working.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now