English 中文(简体)
PHP在员额之后通过阵列结果[复制]
原标题:Passing array results from PHP to jQuery after post [duplicate]

我正试图通过一种PHP的呈文形式将阵列结果退回到 j。 我可以通过<>Toast发出一个成功或失败的信息。

我正在使用:

$ret["icon"] = "success";
$ret["title"] = "Request Deleted Successfully";
echo json_encode($ret);

结果是:

{"icon":"success","title":"Request Deleted Successfully"}

但是,为了激发 object子,我需要

Toast.fire({icon:  success ,title:  Request Deleted Successfully. })

看看差异,我只需要从阵列钥匙中删除 com子,但我如何能够在 j或 Java本中这样做?

问题回答

You receive a JSON string and need to convert it to an object.

const string =  {"icon":"success","title":"Request Deleted Successfully"} ;
const object = JSON.parse(string);
console.log(object.title);

“

• 派遣PHP正确负责人(在任何其他产出之前)

header("Content-Type: application/json");

您应直接从酒吧收到物品,无需打上。

辛勤工作

function(data, status) {
  if (status === "success") {
    if (pageLink == "approverequest") {
      Toast.fire(JSON.parse(data));
      loadDataTableButtons("#requests-container","#project-requests"," .DIR. admin/dashboard/requests");
    } else {
      Toast.fire(JSON.parse(data));
      loadDataTableButtons("#requests-container","#project-requests"," .DIR. admin/dashboard/requests");
    }
  }
});




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签