Php echo json_encode array into javascript array -
I am trying to send a post to a php script which will use this information from all the accounts from the database. ..
var e = document.getElementById ("lstAccounts"); Var Account ID = e.options [e.selectedIndex] .value; Alert ("Account ID:" + Account ID); $ .post ("php / getAccount.php", {ID: accountID}, function (data) {var accountInfo = data;}); In this post, it ...
& lt ;? Php $ id = $ _POST ['id']; ('Database_api.php'); $ Db = new database control; $ Db- & gt; Open_connection (); $ Result = $ db- & gt; Db_query ("SELECT * FROM tblAccount WHERE id = $ id"); $ Account_info = array (); // Get the basic information ($ line = mysqli_fetch_array ($ result)) {$ account_info ['name'] = $ line ['name']; $ Account_info ['CRN'] = $ line ['CRN']; $ Account_info ['id'] = $ line ['id']; $ Account_info ['type'] = $ line ['type']; $ Account_info ['revenue'] = $ line ['revenue']; $ Account_info ['industry'] = $ row ['industry']; $ Account_info ['description'] = $ line ['description']; $ Account_info ['employee'] = $ line ['noif staff']; $ Account_info ['billing'] = $ line ['billingaddresser']; $ Account_info ['shipping'] = $ line ['shippingaddress']; } // Get details $ result = $ db- & gt; Db_query ("SELECT tblDetails.ID, tblDetails.Label, tblDetails.Value FROM tblAccountDetails include in INNER tblDetails.ID = tblAccountDetails.DetailID WHERE Account ID = $ id"); // Get the basic information ($ line = mysqli_fetch_array ($ result)) {$ account_info ['extension'. $ Line ['id']] ['label'] = $ line ['label']; $ Account_info ['extension' $ Line ['id']] ['value'] = $ line ['value']; } // Get contact info // Get invoice // Get payment // Get notes // Get // Return to event // javascript echo json_encode ($ account_info); ? & Gt; I need to recieve json_encode to enter javascript on return data. How do I get that data into the array?
$ Post ("php / getAccount.php", {id: account id}, function (data) {// Here's how to interpret data in a javascript array}} "" "" "" "": "A business's Name "," CRN ": blank," id ":" 17 "," type ":" user "has been set to" revenue ": blank," industry ":" software and an address ". "Extension 75": {"label": "phone", "value": "one", "billing": "one address", "shipping": "" "" "", "description": blank, "employee ": Zero," billing ":" an address "," a phone number "}," extension 76 ": {" Label ":" email "," value ":" an email address "}}" in return
Pass in your data from your php, such as:
... while ($ row = mysqli_fetch_array ($ result)) {$ Account_info ['extension'] $ line ['id'] ] ['Label'] = $ line ['label']; $ account_info ['extension'. $ Line ['id']] ['value'] = $ line ['value'];} echo json_encode ($ account_info ); In the JS section:
$ .post ("php / getAccount.php", {ID: accountID}, function (data) { // Json feedback var response = psesejson = pars; Console.log (feedback); // You can use $. To iterate the data);};
Comments
Post a Comment