Getting information from the server for the gadget (Vista / 7)

Hi everyone ..
I want to get some information from my database and show the sidebar in my gadget (I am new to gadget encoding). I tried many ways to do this, but I have not had time yet.
For this purpose, I prepared a php file to get some values ​​from my database (on the server), and I want to get the content (results) of this php file.

I do not want to use iframes because of visibility.

Actually, I can follow any way to do this. For example:
Retrieving data directly from the database (vulnerability problems), retrieving specified text from php (values ​​placed in special divs) or retrieving all php content and styles in the sidebar using / without GET, POST methods, or any other :)
Thanks right now ...

NOTE : I know (semi-professional) PHP, JavaScript, CSS, but I do not know C #, VB, etc.

+3
source share
1 answer

. ADO, COM-, Windows, . , , - script , . .

PHP XMLHttpRequest(). PHP , . XMLHttpRequest - , . , - ; XML, JSON - . XML JSON , - . PHP 5.2 , JSON . , , json_encode .

XMLHttpRequest

var xhr = new XMLHttpRequest();
xhr.open("GET", "http://mysite.com/test.php", true);
xhr.onreadystatechange = function ()
{
    // readyState 4 = complete, status 200 = HTTP OK
    if (xhr.readyState == 4 && xhr.status == 200)
    {
        parseData(JSON.parse(xhr.responseText)); // parse a JSON response
        // parseData(xhr.responseXML); // parse an XML response
    }
}
xhr.send();

, IE8, JSON.parse() , pre IE8 eval() , ( eval JSON).

:

XMLHttpRequest (MSDN)
JSON JavaScript

+1

Source: https://habr.com/ru/post/1730422/


All Articles