473,387 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to reload a specific div of a page with XMLHTTP

2
Hi,

I have a page (MainPage.aspx) that contains transformed XML data in different divs. The transformation is done in C# with an XML and an XSL file. The requirement is, based on user input , the xml should be updated which will update the page as well.

I have a javascript which takes the input from a input field from mainpage.aspx and sends to the C# code which updates the XML and reloads the page with the Updated XML data.

But I want to refresh only the div whose data is updated rather than the whole Page.

Can I use XMLHTTP request for reloading a specific div of the mainpage.aspx. If yes, is there any example which I can refer?

Appreciate any help.
Oct 23 '07 #1
7 3261
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!
Can I use XMLHTTP request for reloading a specific div of the mainpage.aspx. If yes, is there any example which I can refer?
Yes, of course. See an example. Also check out the Ajax tutorial links in the Off-site Links thread.
Oct 23 '07 #2
sssd
2
the problem I have here is the div contains some xml data and the div needs to be updated when there is an update in xml data.


Expand|Select|Wrap|Line Numbers
  1. xmlHttp.open("GET", url,true);
  2. var str=xmlHttp.responseText
  3.  document.getElementById(div).innerHTML = str;
  4.  
In the above code, we are passing the url of the page that contains the div. so str would contain the text that the whole page contains.And when we pass str to the div, it would display the whole page again in the div.

How can i extract the div from a page.so that i can passonly the div content to the div's innerHtml?
Oct 24 '07 #3
acoder
16,027 Expert Mod 8TB
How can i extract the div from a page.so that i can passonly the div content to the div's innerHtml?
The best way would be to code your server-side script to only return the div and nothing else.

If, for some reason, that isn't possible or you don't wish to change that code, you will have to parse the response text for the div by using DOM methods, e.g. document.getElementById().
Oct 24 '07 #4
Sansha
2
Hi

How can I parse the response text. I dont want to pass the conent of the whole URL, rather I want to pass the contents of a div only.

Is there any example to refer? Thanks
Nov 14 '07 #5
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!
Hi

How can I parse the response text. I dont want to pass the conent of the whole URL, rather I want to pass the contents of a div only.

Is there any example to refer? Thanks
Can you give an example of a response from the server and what you want to parse out from it.
Nov 14 '07 #6
Sansha
2
I have multiple divs in my page. Among them, the div "DivXMLContainer" populates some data from xml data. Now when I add some data to the xml, I want to refresh the div with the updated data.

When I use the xmlhttp.open(Get, URL), I pass the url of the page . Hence the xmlhttp.responsetext gets the whole page .

Now the following line would display the entire page's content inside the div.
document.getelementbyID.("DivXMLContainer").innerH TML= xmlhttp.responsetext


Is there any way , I can parse the 'DivXMLContainer' from the responsetext or is there any other way around?

Let me know if I need to put the XHTML code here.

Thanks
Nov 15 '07 #7
acoder
16,027 Expert Mod 8TB
You could do using responseText.getElementsByTagName("div") and then checking the id.

However, wouldn't it be better to just do this on the server-side instead, i.e. let the server-side code just return the required XML, so there's no need to parse the data.
Nov 16 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Mel | last post by:
i would like to have a link, such that when the user clicks on it, a script is fired to go to server and check for page updates, if any, it should request a reload, else stay silend (terminate) ...
2
by: robert.waters | last post by:
Hello, I am dynamically editing the contents of a page and using document.write() to reload the new, edited content. However, on the new page, any calls to functions located in external .js...
4
by: WAZOO | last post by:
Sorry if this is obvious to everyone (except me). I've done a Google search and I'm not seeing anything encouraging that addresses my issue. My very large multispecialty medical practice needs...
5
by: zorhel | last post by:
Hi. My clients will be IE, Mozilla and Opera in a Windows and *nix OS. So, my web app need to, from a server, send messages to a specific client (browser), send messages for all clients,...
8
by: T. Wintershoven | last post by:
Hi all, Is there a simple way in php to reload a page coded within an if statement.(see code below) It's very important that the session stays intact. The filename is RCStudent.php ...
2
by: defyinggravity | last post by:
Hi this is a newbie alert! This may seem really basic to most, but I am a total beginner, so please don't laugh, or gif me false info...lol I will use it. I have an ajax container loading on my...
3
by: SM | last post by:
Hello, Im trying to access elements in my XML file using the JavaScript DOM but i'm not sure how. I use AJAX to access the XML and then use the responseXML property to access the XML file data. I...
1
by: jborg | last post by:
I have a method to send PHP array values via Ajax to another PHP file that processes my request, however I cannot get it to work here. I know this is normally a basic and very general error, but...
5
by: thatcollegeguy | last post by:
Below are my 3php and 2js files. I create a table using ajax/php and then want to change the values in the tables add(+ number for teamid) id's for each specific td in the table. I don't know...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.