Monday, 8 May 2023

Write an Ajax script to get player details from XML file when user select player name. Create XML file to store details of player (name, country, wickets and runs).

 

<html>

<body>

<script type="text/javascript">

function show_confirm()

{

var r=confirm("Press a button !");

if(r==true)

{

ver i;

var myplayer = new Array();

myplayer[0]="Mysql";

myplayer[1]="PHP";

myplayer[2]="Java";

for(i=0;i {

document.write(myplayer[i]+"

");

}

}

else

{

 

alert("Cancel player cannot br displayed !");

}

}

</script>

</head>

<body>

<input type="button" onclick="show_confirm()" value="List of player"/>

</body>

</html>

 

 

File.xml

<?xml version='1.0' encoding='utf-8'?>

 

 

 

<ABCBOOLK>

<Book>

<name>A</name>

<country>INDIA</country>

<wickets>15</wickets>

<runs>450</runs>

</Book>

 

<Book>

<name>B</name>

<country>AUSTRILIA</country>

<wickets>6</wickets>

<runs>40</runs>

</Book>

 

</ABCBOOLK>