AJAX/Jquery Internet Explorer error

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Nov 2009
Posts: 8
Reputation: calina is an unknown quantity at this point 
Solved Threads: 0
calina calina is offline Offline
Newbie Poster

AJAX/Jquery Internet Explorer error

 
0
  #1
24 Days Ago
Hi guys

I was wondering whether someone could help me with a slight issue I have. I'm trying to set up a quick poll using AJAX which all works fine when using Firefox but running into issues via IE.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. $(function() {
  2. $('.error').hide();
  3. $(".button").click(function() {
  4. var userid = $("input#userid").val();
  5. var name = $('input[name=name]:checked').val();
  6.  
  7. var dataString = 'name='+ name + '&userid=' + userid;
  8.  
  9. $.ajax({
  10. type: "POST",
  11. url: "poll/process.php",
  12. data: dataString,
  13. success: function() {
  14. $('#weekly_poll').html("<div id='message'></div>");
  15. $('#message').html("<h2>Thanks for your vote!</h2>")
  16. .hide()
  17. .fadeIn(500, function() {
  18. $('#message');
  19. });
  20. }
  21. });
  22. return false;
  23. });
  24. });

The issue I'm having is that although the form is being processed OK with data being captured in the database, once the form is submitted, the above script just seems to stop the rest of the page from loading. This only happens on IE and it must be something to do with the success function but as I'm new to JavaScript I don't know what I'm doing wrong.

Can anyway help me please? I think it's something really simple and I'm just being stupid.

Many thanks for reading.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 849
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 138
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark
 
0
  #2
24 Days Ago
I don't know why your specified a callback for the fadeIn, it doesn't appear to do anything. If you change success to the following, what happens ?
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. success: function() {
  2. $('#weekly_poll').html("<div id='message'></div>");
  3. $('#message').html("<h2>Thanks for your vote!</h2>").hide().fadeIn(500);
  4. }
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 8
Reputation: calina is an unknown quantity at this point 
Solved Threads: 0
calina calina is offline Offline
Newbie Poster
 
0
  #3
24 Days Ago
Thanks for replying

Unfortunately still get the same problem Once the form is submitted, all code beneath the form disappears on IE.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 849
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 138
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark
 
0
  #4
24 Days Ago
It's hard for me to test, without having the complete code (html and php), I can only guess at this point, because the code looks okay.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 8
Reputation: calina is an unknown quantity at this point 
Solved Threads: 0
calina calina is offline Offline
Newbie Poster
 
0
  #5
24 Days Ago
OK. Here's all the code for you:

HTML
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <script language="JavaScript" type="text/javascript" src="jquery.js"></script>
  2. <script language="JavaScript" type="text/javascript" src="poll.js"></script>
  3.  
  4. .
  5. .
  6. .
  7. .
  8. .
  9. .
  10. .
  11. .
  12.  
  13. <div style="background-image: url(../images/poll_background_mid.gif); background-repeat: repeat-y; width: 510px;">
  14.  
  15. <div id="weekly_poll" style="padding: 5 0 0 20;">
  16. <form name="poll" action="">
  17.  
  18. <label for="name" id="name_label">Question 1? </font>
  19. <input type="hidden" name="userid" id="userid" value="<?echo $userid;?>"/>
  20. <div style="margin: 5 0 0 0;">
  21. <input type="radio" name="name" id="name" value="Yes" /> Yes
  22. </div>
  23. <div style="margin: 0 0 5 0;">
  24. <input type="radio" name="name" id="name" value="No" /> No
  25. </div>
  26.  
  27. <input type="submit" name="submit" class="button" id="submit_btn" value="Vote" />
  28. </form>
  29. </div>
  30.  
  31. </div>

PHP - poll/process.php
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. include("../include/session.php");
  2.  
  3. $userid = $_POST["userid"];
  4. $answer1 = $_POST["name"];
  5.  
  6. $querypoll = ( "INSERT INTO poll (UserID, Poll, Answer1) VALUES ('$userid','Question here','$answer1')");
  7.  
  8. $resultpoll = mysql_query($querypoll);

JS
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. $(function() {
  2. $('.error').hide();
  3. $(".button").click(function() {
  4. var userid = $("input#userid").val();
  5. var name = $('input[name=name]:checked').val();
  6.  
  7. var dataString = 'name='+ name + '&userid=' + userid;
  8.  
  9. $.ajax({
  10. type: "POST",
  11. url: "poll/process.php",
  12. data: dataString,
  13. success: function() {
  14. $('#weekly_poll').html("<div id='message'></div>");
  15. $('#message').html("<h2>Thanks for your vote!</h2>").hide().fadeIn(500);
  16. }
  17. });
  18. return false;
  19. });
  20. });

Is that everything you need? Many thanks for taking the time to help.
Last edited by calina; 24 Days Ago at 9:36 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 849
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 138
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark
 
0
  #6
24 Days Ago
I uploaded this to my server (saved it as index.php). Appears to be working in IE7 and IE8. Can you confirm ?

  1. <div style="background-image: url(../images/poll_background_mid.gif); background-repeat: repeat-y; width: 510px;">
  2.  
  3. <div id="weekly_poll" style="padding: 5 0 0 20;">
  4. <form name="poll" action="">
  5.  
  6. <label for="name" id="name_label">Question 1? </font>
  7.  
  8. <input type="hidden" name="userid" id="userid" value="<?php echo $userid; ?>"/>
  9.  
  10. <div style="margin: 5 0 0 0;">
  11. <input type="radio" name="name" id="name" value="Yes" /> Yes
  12. </div>
  13.  
  14. <div style="margin: 0 0 5 0;">
  15. <input type="radio" name="name" id="name" value="No" /> No
  16. </div>
  17.  
  18. <input type="submit" name="submit" class="button" id="submit_btn" value="Vote" />
  19. </form>
  20. </div>
  21.  
  22. </div>
  23. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
  24. <script>
  25. $(function() {
  26. $('.error').hide();
  27. $(".button").click(function() {
  28. var userid = $("input#userid").val();
  29. var name = $('input[name=name]:checked').val();
  30.  
  31. var dataString = 'name='+ name + '&userid=' + userid;
  32. alert(dataString);
  33.  
  34. $.ajax({
  35. type: "POST",
  36. url: "process.php",
  37. data: dataString,
  38. success: function() {
  39. $('#weekly_poll').html("<div id='message'></div>");
  40. $('#message').html("<h2>Thanks for your vote!</h2>").hide().fadeIn(500);
  41. }
  42. });
  43. return false;
  44. });
  45. });
  46. </script>
Last edited by pritaeas; 24 Days Ago at 9:43 am.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 8
Reputation: calina is an unknown quantity at this point 
Solved Threads: 0
calina calina is offline Offline
Newbie Poster
 
0
  #7
24 Days Ago
I was testing it out on IE6 which is where the error still occurs
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 849
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 138
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark
 
0
  #8
24 Days Ago
I only have IETester, which shows my code snippet is working in IE6 (http://www.pritaeas.net/public/daniweb/poll/).

Could it be another part of the code ?
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 8
Reputation: calina is an unknown quantity at this point 
Solved Threads: 0
calina calina is offline Offline
Newbie Poster
 
0
  #9
24 Days Ago
I think I may have confused you a little :s

That has never been the issue... the form submits the data to be processed and the thank you message has always shown up. The problem is that the form is at the top of the page with html code below it. When the form gets submitted in IE (version 6 is the one I've tested on) everything below the thank you message disappears. Does that make it clearer for you?

Once again.. thanks for trying to help.
Last edited by calina; 24 Days Ago at 10:41 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 849
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 138
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark
 
0
  #10
24 Days Ago
I see, opera has the same problem, although I cannot explain it at this moment. I'll keep looking.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC