Mimicking Ajax Call with PHP 
 /*********************************************************
|
| Creates Ajax-like request
|
*********************************************************/
function sendRequest($params,$url)
{
$postdata = http_build_query($params);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => "Content-type: application/x-www-form-urlencoded \r\n".
"X-Requested-With: XMLHttpRequest \r\n",
'content' => $postdata
)
);
$context = stream_context_create($opts);
return json_decode(
file_get_contents($url.time(), false, $context)
);
}

$params=array(
'email' => 'me[at]example.com',
'choCountry' => 'Mexico',
'zip' => '91744',
);
$url= 'http://www.barney-example.com/subscribe';
$data = sendRequest($params,$url);



[ view entry ] ( 1597 views )   |  print article

<<First <Back | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Next> Last>>



2024 By Angel Cool