[英]Insert json_encode() array into javascript function
嗨,我正在使用ajax從php獲取json_encode()數組並將其存儲到變量中。 我該如何將該數組插入javascript函數?
c = (parseInt(e.attr("data-invoice-id")), {
//insert that array here
}),
它應該看起來像這樣。
c = (parseInt(e.attr("data-invoice-id")), {
invoice_id: {
invoice_number: "Some Value",
invoice_orderno: "Some Value",
invoice_date: "Some Value",
invoice_due_date: "Some Value",
invoice_from_company: "",
invoice_from_address_1: "",
invoice_from_address_2: "India",
invoice_to_company: "Some Value",
invoice_to_address_1: "2894 Bond Street",
invoice_to_address_2: "Providence, RI 02908",
invoice_total_value: "Some Value",
invoice_vat_value: "00.00",
invoice_device: "Some Value",
invoice_dproblem: "Some Value",
invoice_dserial: "Some Value",
invoice_payment_info: "Cash On Delivery<br/>(COD)",
invoice_payment_due: "14"
}
}),
請幫助,我是javascript的初學者
將php json_encode數組存儲在變量中
var data=xmlhttp.responseText;
然后只需使用JSON.parse
解析數組
c = (parseInt(e.attr("data-invoice-id")), {
var obj = JSON.parse(data)
}),
大功告成!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.