Solved

Click form button, refresh <div> with JQuery

Posted on 2010-09-01
6
1,323 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
Comment Utility
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
Comment Utility
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
Comment Utility
It surely appears to be a jQuery conflict with another library.

Try replacing the "$" in your code with "jQuery" and try it again.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 30

Author Comment

by:Wayne Barron
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

762 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

9 Experts available now in Live!

Get 1:1 Help Now