Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #33569

Re: Getting text with AJAX

Path csiph.com!aioe.org!.POSTED!not-for-mail
From JR <jrfaqcom@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: Getting text with AJAX
Date Sun, 2 Jul 2017 13:37:35 -0300
Organization Aioe.org NNTP Server
Lines 24
Message-ID <ojb7ge$15f8$1@gioia.aioe.org> (permalink)
References <31a6bc47-820d-4029-9ff1-c46617cf7e6f@googlegroups.com>
NNTP-Posting-Host u/4eDfQhPL5v/CkxJ2Tjew.user.gioia.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Complaints-To abuse@aioe.org
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1
X-Notice Filtered by postfilter v. 0.8.2
Content-Language en-US
Xref csiph.com comp.lang.javascript:33569

Show key headers only | View raw


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


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