javascript - Use a variable in PhP script passed by $http.post -


$ http.post to use any kind of revenue for php scripts Use this ID for mysql request to send ID.

This is my controller:

  function ProjectDetailsCtrl ($ scope, $ http, $ timeout, getGoodIdProjectDetails) {$ scope.idProjectDetails = getGoodIdProjectDetails.getId (); // ID Project Getting $ Range $ Emit ('LOAD') $ scope.url = 'Script / Find ProjectDetails.php'; $ Http.post ($ scope.url, {"idProject": $ scope.idProjectDetails}) Success (jobs (data, status) {$ scope.projectDetails = {}; $ scope.projectDetails.details = details; $ scope $ Emit ('UNLOAD')}) Error (function (data, position) {$ scope.data = data || "request failed"; $ scope.status = status;}); }  

idProjectDetails is a number.

then php script:

  & lt; Php $ IdProject = json_decode ($ _ POST ['idProject']);  

Returns the php script that $ idProject is undefined.

Can you help me with this?

EDIT: I tried this way but my app crashed with it:

  $ http.defaults.headers.post ["content-type"] = "Application / x-www-form-url expired"; $ Http ({method: 'POST', url: 'scripts / findProjectDetails.php', data: "idProject": $ scope.idProjectDetails}). Success (work, data, status) {$ scope.projectDetails = {}; $ Scope.projectDetails.details = Data; Console.log (projectDetails.details); $ Scope $ Emit ('UNLOAD')}) Error (function (data, position) {$ scope.data = data || "request failed"; $ scope.status = status;});  

With the first example, in the Chrome console, "Request Playload" includes: {idProject: 1} idProject: 1 So I think my variable has been passed correctly through PHP script? There is a lot of confusion as to why the $ http service shorthand function ($ http.post (),

Etc.) are not swapable with jQuery equivalents (jQuery.post (), etc., as newcomers to AngularJS, how the difference is in jQuery, and AngularJS serializes and transmits data. The server is with the choice of language which is unable to understand the transmission of fingerprints ... by default, JQuery transmits data using the content-type: x-www-form-urlencoded and familiar foo = bar & amp; baz = moe serialization.AngelserJes, however, content-type: app / jason and {"foo": "Bar", "Falcon": "Mo") transmits data, which unfortunately some web server languages ​​- especially PHP - is not originally undefined.

< / P>

/ li>
  • (dislikes but works )
  • I have nothing here Oj is not, just add ... hope it will help.


    Comments

    Popular posts from this blog

    winforms - C# Form - Property Change -

    java - Algorithm negotiation fail SSH in Jenkins -

    java - Messages from .properties file do not display UTF-8 characters -