【发布时间】:2016-03-08 10:12:32
【问题描述】:
我需要一些帮助来发送我的数据。
首先,我工作的脚本被用作 Nagios 的 Mass Acknoledgments 工具,其灵感来自 NagiosXI 的可购买组件。我最后开发了它,数据处理/发送完全在 PHP 中。实际上,我更新了我的脚本,为此,我需要使用 AJAX。
我遇到的问题是这样的:下面是我的表单的屏幕,生成它的 html 代码,Chrome 调试工具的屏幕,向您展示我的数据是如何发送的,以及用于数据检索的 PHP 代码。
<tr>
<td class="OK">168VWL1</td>
<td><a href="javascript:checkAll('host1');">Check all for this hosts</a></td>
<td class="empty"></td>
<td class="empty"></td>
<td class="empty"></td>
<td class="empty"></td>
</tr>
<tr>
<td class="empty"></td>
<td class="critical"><input class="host1 servicecheck" type="checkbox" name="services[]" value="168VWL1::Explorer">Explorer</td>
<td class="output">Explorer.exe: not running</td>
<td class="centerd"><input type="checkbox" class="sticky" name="sticky[]" value="168VWL1::Explorer"></td>
<td class="centerd"><input type="checkbox" class="notify" name="notify[]" value="168VWL1::Explorer"></td>
<td class="centerd"><input type="checkbox" class="persist" name="persist[]" value="168VWL1::Explorer"></td>
</tr>
if(isset($_POST['hosts'])){
$allHosts = json_decode($_POST['hosts']);}
if(isset($_POST['services'])){
$allServices = json_decode($_POST['services']);}
if(isset($_POST['sticky'])){
$allStickys = json_decode($_POST['sticky']);}
if(isset($_POST['notify'])){
$allNotifys = json_decode($_POST['notify']);}
if(isset($_POST['persistent'])){
$allPersistents = json_decode($_POST['persistent']);}
如您所见,通过这种方式,在 PHP 中处理我的数据非常简单,只需一个调用,我的数组就已经生成了。
现在,因为我使用 AJAX,所以我不知道如何以同样的方式发送这个。有什么建议吗?
【问题讨论】:
标签: php jquery html ajax nagios