473,406 Members | 2,356 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,406 software developers and data experts.

Ajax

I am trying a small ajax program, in which i am trying to load the content of page which is coded in HTML in to another page which is existing already in browser(loaded in browser). The problem is i am getting the content of second one in HTML syntax also(HTML code also). How can i avoid the HTML syntax from the user as presentation.
Nov 19 '07 #1
3 943
gits
5,390 Expert Mod 4TB
hi ...

welcome to TSDN ...

could you post the code you use ... so that we may have a closer look at it?

kind regards
Nov 19 '07 #2
<!-- FirstPage.html -->

[HTML]<html>
<head>
<title>Ajax Testing</title>

<script type="text/javascript" language="javascript">



function AjaxRequest(url) {

var http_request = false;

if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
// See note below about this line
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}

if (!http_request) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
http_request.onreadystatechange = function() { showhtmlpageContents(http_request); };
http_request.open('GET', url, true);
http_request.send(null);

}

function showhtmlpageContents(http_request) {

if (http_request.readyState == 4) {
if (http_request.status == 200) {
alert(http_request.responseText);
} else {
alert('There was a problem with the request.');
}
}

}
</script>
</head>
<body>
<a href

onclick="AjaxRequest('SecondPage.html')">
Call page using Asynchronous javascript and xml
</a>


</body>
</html>[/HTML]



<!--SecondPage.html
The Second page I am calling from First page -->

[HTML]<html>
<head>Ajax response</head>
<body>
Ajax
</body>
</html>[/HTML]
Nov 27 '07 #3
When you alert responseText the entire content that has been passed will be alerted i.e the entire HTML page.But when you load the page i.e show on internet browser,only HTML content shown
For example you can have 'div' with id say loadedpage
Expand|Select|Wrap|Line Numbers
  1. <div id=loadedpage></div>
When the xmlhttp response comes just write
Expand|Select|Wrap|Line Numbers
  1. var loaddiv=document.getElementById('loadedpage');
  2. loadddiv.innerHTML=xmlhttpobject.responseText;
  3.  
i.e div is loaded with content of HTML and not syntax
Nov 27 '07 #4

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

Similar topics

11
by: Yarco | last post by:
I want to use "Ajax" to create my web for hobby. But i don't know whether "Ajax" is mature... And what about with php? Someone have experience on it? ....
4
by: bobzimuta | last post by:
I'm creating a simple AJAX library. It's an object that will return an array containing the response text or xml. I'm trying to find a way to assign the response as a property of the object, but...
0
by: melledge | last post by:
Ajax Developers' Day added to XTech 2006 agenda XTech 2006 - 17-19 May - Hotel Grand Krasnopolsky - Amsterdam, The Netherlands
0
by: melledge | last post by:
Ajax Developers' Day added to XTech 2006 agenda XTech 2006 - 17-19 May - Hotel Grand Krasnopolsky - Amsterdam, The Netherlands
1
by: www.web20developers.com | last post by:
http://www.web20developers.com http://www.web20developers.com/index.php?option=com_content&task=view... Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell AJAX -...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.