|
Posted by Vladdy on 10/10/96 11:26
Roy Schestowitz wrote:
> __/ [Neredbojias] on Monday 12 September 2005 05:44 \__
>
>
>>With neither quill nor qualm, Neredbojias quothed:
>>
>>
>>>With neither quill nor qualm, Roy Schestowitz quothed:
>>>
>>>
>>>>I would like to retrive some raw information (text) from one machine
>>>>and display it within a page in another. I was thinking about using
>>>>JavaScript that will fetch the text from a given URL and add it to the
>>>>body. Does someone know a page or example which I can re-use? I hope I
>>>>explained this clearly enough. If not, follow up with question.
>>>
>>>Check out the following link. It does what _I think_ you want. If you
>>>need more info beyond the html, I'll be here.
>>>
>>>http://www.neredbojias.com/alpha/jokes.html
>
>
>
> Thank you for the link. I have had a quick look (nice design by the way).
>
>
>
>>Oops, check that. It does it in PHP, no javascript needed. Originally
>>it was javascript but I must have changed it before I went senile.
>>
>>You can use javascript to do the same thing, -just pick-off the
>>search/query strings with js instead of PHP and make a .js file instead
>>of a text file with variablized text.
>
>
>
> The problem is that PHP, being server-side does not expose the code. I was
> hoping for a quick grab of JavaScript code. Also, renaming the page/s,
> namely having the html suffix changed to php, will require modification of
> internal links, or even worse, external inbound links. Redirections would
> be an overkill.
>
> 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.
--
Vladdy
http://www.klproductions.com
Navigation:
[Reply to this message]
|