| Author | Moises Lima |
| Version | 1.03 |
| License: | GPL |
| Date Added: | May 7, 2009 |
| Download URL: | Source Code (PHP 5) |
The class class.XMLHttpRequest.php is easiest way of using PHP cURL library, it's uses "XMLHttpRequest" syntax to work with cURL.
A basic example of the requisition process using HTTP GET method.
<?php
require_once('class.XMLHttpRequest.php');
$ajax = new XMLHttpRequest();
$ajax->open("GET","http://www.google.com" );
$ajax->send(null);
if($ajax->status == 200){
echo $ajax->responseText;
}else echo "ERROR: $ajax->status";
?>
A basic example of the requisition process using HTTP POST method.
<?php
require_once('class.XMLHttpRequest.php');
$ajax = new XMLHttpRequest();
$ajax->open("POST","http://www.google.com/translate_t" );
$ajax->send("langpair=pt|en&text=cachorro");
if($ajax->status == 200){
echo $ajax->responseText;
}else echo "ERROR: $ajax->status";
?>
A basic example of the requisition process using HTTP TRACE method.
<?php
require_once('class.XMLHttpRequest.php');
$ajax = new XMLHttpRequest();
$ajax->open("TRACE","http://www.opera.com/" );
$ajax->send(null);
if($ajax->status == 200){
echo $ajax->getAllResponseHeaders();
echo $ajax->responseText;
}else echo "ERROR: $ajax->status";
?>
A basic example of the requisition process using HTTP HEAD method.
<?php
require_once('class.XMLHttpRequest.php');
$ajax = new XMLHttpRequest();
$ajax->open("HEAD","http://www.opera.com/" );
$ajax->send(null);
if($ajax->status == 200){
echo $ajax->getAllResponseHeaders();
}else echo "ERROR: $ajax->status";
?>
A basic example of the requisition process at XML document.
<?php
require_once('class.XMLHttpRequest.php');
$ajax = new XMLHttpRequest();
$ajax->open("GET","http://www.xml.com/2000/11/29/schemas/library1.xml" );
$ajax->send(null);
if($ajax->status == 200){
if($ajax->responseXML !=null && gettype($ajax->responseXML) == "object"){
$dom = $ajax->responseXML;
$params = $dom->getElementsByTagName('character');
echo '<table border="1"><tr><th>name</th><th>since</th><th>qualification</th></tr>';
foreach ($params as $param) {
echo '<tr><td>'.$param->getElementsByTagName('name')->item(0)->textContent.'</td><td>'
.$param->getElementsByTagName('since')->item(0)->textContent.'</td><td>'
.$param->getElementsByTagName('qualification')->item(0)->textContent.'</td></tr>';
}
echo "</table>";
}else echo "ERROR: $ajax->error";
}else echo "Status: $ajax->status ERROR: $ajax->error";
?>
Comments
its really a perfect guide
its really a perfect guide for using XMLHttpRequest with curl. i have saved the url on my bookmark netwotkIos On Android Phone
The download link does not seem to work
I have been trying to download your class since yestarday, but I always end up with a "page not found" message. Could you please check that? Thanks!
I use cURL everytime, it's
I use cURL everytime, it's wonderful ! I was searching something like that and you did it.
Thank you guy ;)
Amelie, webmaster of Dora jeux, free games of Dora the explorer.
Re: Using Ajax with PHP
Hi,
Here is also a nice one article on searching text using ajax in php, you may check out the this link for more details...
http://www.mindstick.com/Articles/aa044953-9f8c-4666-932e-946b2d5bc7ef/?Using%20AJAX%20with%20Database%20in%20PHP
Thanks !!!
download url dont works can
download url dont works can you fix that?
please :)
Awesome
Thanks so Much !
thanks.
its really a perfect guide for using XMLHttpRequest with curl. i have saved the url on my bookmark netwotk. (;
Thank you!
Thank you! This is very good class!
Nice :D
Nice :D
very good!
very good!
and for php 4?
and for php 4?
Very Good class
This is very good class: Web Design
Thank you!
Thank you!
Post new comment