Hi Friends
In this section will see
Why XMLHttpRequest Object?
Basic Syntax for creating XMLHttpRequest Object and ActiveX Object
Variable_name(object_name)= new HttpRequest(); This is Modern Browser
Varibale_name(object_name)= new ActiveXObject("Microsift.XMLHTTP") This is Older Browser
How to Create XMLHttpRequest Object and ActiveX Object in one way
<head>
<script>
function myfunction()
{
var xhttp;
if (window.XMLHttpRequest)
{
xhttp = new XMLHttpRequest(); // Modern browser
}
else
{
xhttp = new ActiveXObject("Microsoft.XMLHTTP"); // Older browser
}
}
</script>
</head>
How to Check your browser Modern/Older Browser
<html>
<title>XMLHttpRequest Object</title>
<script>
function myfunction()
{
var xhttp;
if (window.XMLHttpRequest)
{
xhttp = new XMLHttpRequest(); // Modern browser
alert("You have Modern Browser!")
}
else
{
xhttp = new ActiveXObject("Microsoft.XMLHTTP"); // Older browser
alert("You have Older Browser!")
}
}
</script>
</head>
<body>
<input type="submit" name="submit" value="Check Browser" onclick="myfunction()" />
</body>
</html>
This above code
I hope this section can clear your doubts and how to create and use in your script..
Thank you!
In this section will see
- Why Create XMLHttpRequest Object?
- How to Create XMLHttpRequest Object?
- Examples XMLHttpRequest Object
Why XMLHttpRequest Object?
- The XMLHttpRequest Object is used to to Exchange data with Server. this meas that is possible to update part of webpage without reloading the whole webpage.
- All modern Browsers supports XMLHttpRequest Object because all moders browsers have built in this object.
- If older browesr like IE below version we can create ActiveX Object
Basic Syntax for creating XMLHttpRequest Object and ActiveX Object
Variable_name(object_name)= new HttpRequest(); This is Modern Browser
Varibale_name(object_name)= new ActiveXObject("Microsift.XMLHTTP") This is Older Browser
How to Create XMLHttpRequest Object and ActiveX Object in one way
<head>
<script>
function myfunction()
{
var xhttp;
if (window.XMLHttpRequest)
{
xhttp = new XMLHttpRequest(); // Modern browser
}
else
{
xhttp = new ActiveXObject("Microsoft.XMLHTTP"); // Older browser
}
}
</script>
</head>
How to Check your browser Modern/Older Browser
<html>
<title>XMLHttpRequest Object</title>
<script>
function myfunction()
{
var xhttp;
if (window.XMLHttpRequest)
{
xhttp = new XMLHttpRequest(); // Modern browser
alert("You have Modern Browser!")
}
else
{
xhttp = new ActiveXObject("Microsoft.XMLHTTP"); // Older browser
alert("You have Older Browser!")
}
}
</script>
<body>
<input type="submit" name="submit" value="Check Browser" onclick="myfunction()" />
</body>
</html>
This above code
- window.XMLHttpRequest supports will show msg in Modern Browser and we create that xhttp object for XMLHttpRequest method.
- if does not support will show msg older browser and we create xhttp object for ActiveXObject Method.
I hope this section can clear your doubts and how to create and use in your script..
Thank you!
No comments:
Post a Comment