Tuesday, April 23, 2013

Getting json data using php curl


        get_json.php:
~~~~~~~~~~~~~

$arr = "your array result";
        echo json_encode($arr);


json_result.php:
        ~~~~~~~~~~~~~~~~

$url  = 'get_json.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 1);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Accept: application/json', "Content-type: application/json"));
curl_setopt($ch, CURLOPT_URL, $url );

$return = curl_exec($ch);

curl_close ($ch);
$result = json_decode($return,true);

Bind Some Event to Element and trigger that function when click the element

Scenario: Suppose if we used same click event function in various web pages. if you want do some logic some page button for that need to re...