Solved

Click form button, refresh <div> with JQuery

Posted on 2010-09-01
6
1,330 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
  • 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 30

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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 30

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 30

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 30

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create an automated page index 9 53
how can i make 2 columns? 4 42
Getting search results to display ul for text field being inputted into 43 59
Search Item in Table 2 23
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

820 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