Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Click form button, refresh <div> with JQuery

Posted on 2010-09-01
6
Medium Priority
?
1,335 Views
Last Modified: 2012-08-13
Hello All

I am converting all my extremely load code with shorter more flexable code.
The below I found for clicking a link to refresh a div.

This is not working?
My Button
<input type="submit" name="Submit" value="Save"  class="lButton" id="Save" />
<div id="tableContainer">content here</div>
my code---------------
$(function() {
      $("#Save").click(function(evt) {
         $("#tableContainer").load("http://site.com/Server/MyRefreshBox.asp")
         evt.preventDefault();
		 return false;
      })
    })

Open in new window



I also have this code, which refreshing on a timer.
Would love to get it to work if possible on a Button click

var auto_MemLoad = setInterval(
function()
{
$('#MemLoad').fadeOut('slow').load('http://site.com/Server/MyRefreshBox.asp').fadeIn("slow");
}, 30000);

Open in new window


Any ideas would be great on this issue.

Thank You
Carrzkiss
0
Comment
Question by:Wayne Barron
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 6

Expert Comment

by:M. Rashel Ahmed
ID: 33574639
you will find the answer here at: http://forums.asp.net/t/1130175.aspx


0
 
LVL 31

Accepted Solution

by:
Wayne Barron earned 0 total points
ID: 33574688
ASbsolutely no help on that page.
Thanks anyway.

I have found a solution to my issue, which is to use what I have which is the provided code below.

Take Care
Carrzkiss
function MyRefreshBox(){
var xmlHttpCor;
	try{	
		xmlHttpCor=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
	}
	catch (e){
		try{
			xmlHttpCor=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
		}
		catch (e){
		    try{
				xmlHttpCor=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
				alert("No AJAX!?");
				return false;
			}
		}
	}
xmlHttpCor.onreadystatechange=function(){
	if(xmlHttpCor.readyState==4){
		document.getElementById('tableContainer').innerHTML=xmlHttpCor.responseText;		
	}
}
xmlHttpCor.open("GET","http://site.com/Server/MyRefreshBox.asp",true);
xmlHttpCor.send(null);
}

Open in new window

0
 
LVL 1

Expert Comment

by:ValiMihai
ID: 33574847
It surely appears to be a jQuery conflict with another library.

Try replacing the "$" in your code with "jQuery" and try it again.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 31

Author Comment

by:Wayne Barron
ID: 33580699
Thanks for your input Vali
What I am using now, is working so I am going to stick with it.
I will look in on this issue at a later date if the code is needed.

Thank You
Carrzkiss
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 33582056
I just ran into an issue with Google Chrome and IE8 not refreshing on the button submit
FireFox is working as expected.

So.

Back to the other code.
I did as you suggested and still a no-go.


Any idea's (or) better yet, and actual working code would be GREAT! about now.
That works across all browser platforms.

Thank all;
Carrzkiss
jQuery(function() {
      jQuery("#Save").click(function(evt) {
         jQuery("#tableContainer").load("http://site.com/")
         evt.preventDefault();
		 return false;
      })
    })

Open in new window

0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 33585522
I am set.
Everything is working now.

I had to remove this part from the code.
                    if(xmlHttpCor.readyState==4){
}

Once I removed it, IE8 started refreshing OnSubmit of the form.

This part will function in IE6 and IE7
But will not function in IE8 and has to be removed in order to refresh the page on Form Submit.

Take Care All;
Carrzkiss
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

610 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