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);



Comments
Comments are not available for this entry.
2024 By Angel Cool