我發送給我的PHP的jQuery變量不起作用(或者至少,它似乎不起作用)。我用ajax將它發送給我的php。PHP如果語句不能與jQuery變量一起工作
請看看它,或許你可以看到問題:
$('.do').click(function(){
var cid2 = $(this).attr('id');
var gebridauthpos = cid2.indexOf('||');
var gebridauth = cid2.substring(gebridauthpos+2);
$.post("agenda.php", {gebridauth: gebridauth});
alert(gebridauth);
<?php
if ($admin == true || isset($_POST['gebridauth']) AND $_SESSION['id'] == $_POST['gebridauth']) {
echo "$('#dialog').dialog('open');\n";
echo "var cid = $(this).attr('id');\n";
echo "var datum = cid.substr(0, 10);\n";
echo "var naampos = cid.indexOf('|');\n";
echo "var gebridpos = cid.indexOf('||');\n";
echo "var naam = cid.substring(naampos+1,gebridpos);\n";
echo "var gebrid = cid.substring(gebridpos+2);\n";
echo "$.ajax({\n";
echo "type: \"POST\",\n";
echo "url: \"agenda.php\",\n";
echo "data: naam,\n";
echo "success: function(){\n";
echo "$('#gebruikerinput').html(\"<input type='text' READONLY='' size='35' value='\" + naam +\"'>\");\n";
echo "$('#gebridinput').html(\"<input type='hidden' name='gebridtextbox' value='\" + gebrid + \"'>\");\n";
echo "$('#datuminput').html(\"<input type='text' READONLY='' size='12' name='datum' value='\" + datum + \"'>\");\n";
echo "}\n";
echo "})\n";
echo "return false;\n";
}
?>
});
基本上就是我想要做的,是用「gebridauth」在我的PHP的if語句,當我點擊一個TD 。如果TD與登錄人員相同,則顯示對話框。
迴應每一行JS *和*轉義引號?讀這傷害。 – ThiefMaster
什麼是agenda.php? –
Agenda.php是代碼所在的當前PHP。它基本上會生成一個包含數據的表。 – Yihka