Client code:
var param = $.param (
{
Feed:JSON.stringify ({
Content: ' ABCD '
})
}
);
$http ({
URL: ' http://61.153.100.80/pay/talent.php ',
Method: "POST",
Data:param,
Headers: {' content-type ': ' application/x-www-form-urlencoded '}
}). Success (function (data, status, headers, config) {
$ (' #dvTalent '). HTML (data.talent);
}). Error (Function (data, status, headers, config) {
});
$.ajax ({
Type: ' Post ',
URL: ' http://61.153.100.80/pay/talent.php ',//i has the actual URL here's course
Cache:false,
ContentType: ' application/x-www-form-urlencoded ',
Crossdomain:true,
Success:function (data) {
alert (data.talent);
Doing stuff with data on here
}, Error:function (JQXHR, Textstatus, Errorthrown) {
Alert (' Critical error. Everything is exploding. Abort mission. ');
}
});
PHP service-side code returned {"Talent": 32}
<?php
error_reporting (0);
Header (' access-control-allow-origin:* ');
Header (' access-control-allow-headers:authorization ');
Header (' Content-type:application/json; Charset=utf-8 ');
Header (' access-control-allow-methods:put,post,get,delete,options ');
echo json_encode (Array (' talent ' =>132));
HTML5 client cross-domain access to PHP service-side data