Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-05-2012, 03:26 PM   PM User | #1
Jigar
New to the CF scene

 
Join Date: Oct 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Jigar is an unknown quantity at this point
How can i update xml file click on the button

this is my function...plz help me.....
function upDate()
{
xmlhttp.open("GET","xmlf/emp.xml",false);
xmlhttp.send(null);
xmlDoc=xmlhttp.responseXML;
var x=xmlDoc.getElementsByTagName("Student");
for(i=0;i<x.length;i++)
{
if(document.getElementById("se").value == x[i].getElementsByTagName("Name")[0].childNodes[0].nodeValue){
var a = x[i].getElementsByTagName("Address")[0].childNodes[0].nodeValue = document.getElementById("address").value;
alert(x[i].getElementsByTagName("Address")[0].childNodes[0].nodeValue = document.getElementById("address").value);
alert("In");
}
}
alert("end");
}
Jigar is offline   Reply With Quote
Old 10-11-2012, 01:36 AM   PM User | #2
Jimmaay
New to the CF scene

 
Join Date: Oct 2012
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
Jimmaay is an unknown quantity at this point
Code:
	var xmlhttp = new XMLHttpRequest(); // You must Initialize
	xmlhttp.open("GET","x.xml",false); // async is false, which is fine, but try async sometime
	xmlhttp.send(); // no need for null
	var x=xmlhttp.responseXML.getElementsByTagName("Student"); // only need one variable
	for(var i=0,j=x.length;i<j;i++){ // DECLARE VARIABLE if "i" is defined in window then it'll be overwritten
           Code in for loop should be fine 
        }
When it comes to reponseXML your XML MUST be VALID to your browser expecially. This code was tested on Chrome 22.
Jimmaay is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:59 PM.


Advertisement
Log in to turn off these ads.