|
Posted by Roy Schestowitz on 10/08/46 11:26
__/ [Vladdy] on Monday 12 September 2005 07:51 \__
> Roy Schestowitz wrote:
>> __/ [Neredbojias] on Monday 12 September 2005 05:44 \__
>>
>> <SNIP>
>>
>> To rephrase my request as you were not sure what I meant, I seek to grab
>> text from http://example.org/data.txt and then embed it in a <span>, for
>> instance, in http://example.com/page.html. data.txt gets updated all the
>> time, hence it needs to be grabbed. If JavaScript was disabled, there
>> would be no harm either.
>>
>> Thanks again,
>>
>> Roy
> function getFile(filename)
> { oxmlhttp = null;
> try
> { oxmlhttp = new XMLHttpRequest();
> oxmlhttp.overrideMimeType("text/xml");
> }
> catch(e)
> { try
> { oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
> }
> catch(e)
> { return null;
> }
> }
> if(!oxmlhttp) return null;
> try
> { oxmlhttp.open("GET",filename,false);
> oxmlhttp.send(null);
> }
> catch(e)
> { return null;
> }
> return oxmlhttp.responseText;
> }
>
> function returns file content as text string.
> beware of x-domain scripting restrictions.
Thank you very much for the reply.
Below is the code that I have added as a wrapper. I still have a slight
problem, which perhaps you can solve 'on the spot'. The following
simplified example will work fine (I do not know JS methods):
[CODE]
function showInfo()
{
oxmlhttp =getFile('/robots.txt');
document.write(oxmlhttp);
}
[/CODE]
but the following will not
[CODE]
function showInfo()
{
oxmlhttp =getFile('http://example.org/robots.txt');
document.write(oxmlhttp);
}
[/CODE]
Is there a simple way around this? The text remains 'null' if I try the
latter, which is why I need to access a machine of mine from the Web
server.
Thanks again,
Roy
--
Roy S. Schestowitz | (S)oftware (U)nd (S)ystem(E)ntwicklung
http://Schestowitz.com | SuSE Linux | PGP-Key: 74572E8E
1:55pm up 18 days 9:01, 3 users, load average: 1.76, 1.70, 1.32
Navigation:
[Reply to this message]
|