use*_*366 4 javascript json toastr
我正在尝试从通过 AJAX 检索的 JSON 中显示一条 toastr 消息。这必须能够更改警报的类型及其内容。我对 JSON 不太聪明,读了一段时间后我仍然不知道从哪里开始。有什么指点吗?
阿贾克斯:
function ping(data1)
{
$.ajax({
type: "POST",
url: "bridge/ping.php",
data: "var1="+data1,
success:
}
});
Run Code Online (Sandbox Code Playgroud)
烤面包机:
toastr.success("Message here","Title here)
Run Code Online (Sandbox Code Playgroud)
基本上在 PHP 端,您将发回一个编码的 JSON,如下所示:
$arr = array('message' => 'your message here', 'title' => 'your title here');
echo json_encode($arr);
Run Code Online (Sandbox Code Playgroud)
现在,在您的客户端上,您编写success:
success: function(data) {
toastr.success(data.message, data.title);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18603 次 |
| 最近记录: |