Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #33569
| From | JR <jrfaqcom@gmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Getting text with AJAX |
| Date | 2017-07-02 13:37 -0300 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <ojb7ge$15f8$1@gioia.aioe.org> (permalink) |
| References | <31a6bc47-820d-4029-9ff1-c46617cf7e6f@googlegroups.com> |
On 01-07-2017 06:49, bit-naughty@hotmail.com wrote:
> ...OK, so assume there's some text on the screen, like a headline, or
> topic, say. When it's clicked, the actual text has to be got (from
> the server), and shown. What would the coding look like? (assume the
> text itself is on a MySQL db on the server, with some kind of "id" to
> it, which will be fetched by a PHP script - ie.
> www.site.com/gettext.php?articleid=210).
>
The client side code for the click event handler might be something like
this:
var div = document.getElementById('div_id');
var xhr = new XMLHttpRequest();
xhr.open('GET', 'gettext.php?articleid=210');
xhr.onload = function () { // Request has successfully completed.
if (xhr.status === 200) {
div.innerHTML = xhr.responseText;
}
};
xhr.send();
--
Joao Rodrigues
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Getting text with AJAX bit-naughty@hotmail.com - 2017-07-01 02:49 -0700 Re: Getting text with AJAX Luuk <luuk@invalid.lan> - 2017-07-01 11:56 +0200 Re: Getting text with AJAX Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-07-01 12:10 +0100 Re: Getting text with AJAX JJ <jj4public@vfemail.net> - 2017-07-01 21:35 +0700 Re: Getting text with AJAX JR <jrfaqcom@gmail.com> - 2017-07-02 13:37 -0300
csiph-web