Solved

Click form button, refresh <div> with JQuery

Posted on 2010-09-01
6
1,329 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
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 …
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…

803 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