javascript - HTTP post request - difference between AngularJS and JQuery -
what true difference between http post requests run angularjs , jquery?
angularjs:
$http.post(requesturl, {'data':mydata}) jquery:
$.post(requesturl,{data : data} on php backend, have run 2 different mechanisms read data. angularjs works reason
$params = json_decode(file_get_contents('php://input'), true); $data = $params['data']; jquery works standard
$data = $_post['data'] how can fix angularjs run on "normal" $_post trail?
both fail opposite php strategy.
the difference default content types different.
jquery $.ajax uses application/x-www-form-urlencoded
angular $http uses application/json
both api's provide options switch content type .
$http has serialization service $httpparamserializerjqlike form encode , opposite use json.stringify() `$.ajax
Comments
Post a Comment