我可以在getJSON中搜索特定的值,然后执行正确的PHP吗?
作为我的web应用程序的一部分,我创建了一个按钮,点击事件将向用户移动设备(android或ios)发送推送消息 我面临两个挑战: 首先:检查该值以决定是否需要将其传递给android或ios PHP脚本。 我不知道如何用JS编写代码,但在PHP上应该是这样的:我可以在getJSON中搜索特定的值,然后执行正确的PHP吗?,php,onclick,event-handling,gson,Php,Onclick,Event Handling,Gson,作为我的web应用程序的一部分,我创建了一个按钮,点击事件将向用户移动设备(android或ios)发送推送消息 我面临两个挑战: 首先:检查该值以决定是否需要将其传递给android或ios PHP脚本。 我不知道如何用JS编写代码,但在PHP上应该是这样的: <?php $token= 'APA34324324343'; $findme = 'APA'; $pos = strpos($token, $findme); if ($pos === false) { exec(
<?php
$token= 'APA34324324343';
$findme = 'APA';
$pos = strpos($token, $findme);
if ($pos === false) {
exec("ios_push.php $token > /dev/null &");
} else {
exec("andorid_push.php $token > /dev/null &");
}
?>
第二:在$.getJSON函数中编写正确的语法,该函数将接受$值并将其传递给正确的PHP脚本。
这就是我现在拥有的:
'<button onclick="' .
"var activeValue = $(this).siblings('.user_token_value');" .
"var activeCaption = $(this).siblings('.user_token_caption');" .
"$.getJSON(
'send_push.php?id=" . $rowData['token'] .
'