About Pi Downloads Documentation Plugins Developer Forum Issues

pi.xhr.get

Summary

Sends a synchronic request and returns a XMLHttpRequest object.

Syntax

pi.xhr.get(url)

Usage Example

>>> var req = pi.xhr.get("data.txt");
>>> req
XMLHttpRequest
>>> req.responseText
"You're not your job. You're not how much money you have in the bank. You're not the car you drive."

Examples

Example #1: Get the unixtime from printUnixtime.php

Source files of the above example:

../../getUnixtime.html

<div id="time"></div>

../../getUnixtime_get.js

pi.get("time").innerHTML=pi.xhr.get("../../unixtime.php").responseText;

../../unixtime.php

<? print time(); ?>