JQuery没有发帖?

时间:2013-09-16 09:00:36

标签: php jquery

我正在使用此代码:

$.post('private.php', { name: $(this).val() });

我知道$(this).val()是有效的,因为它也会记录到我的控制台。

我在PHP中打印$ POST变量

print_r($_POST);

但所有显示的内容都是:Array()

为什么JQuery不将我的变量发送到php?

文件:

的script.js

$(document).ready(function() {
    //Changes the classes based on selection
    var selected = 'none';
    $('select').change(function(){
        $(this).parent().attr("class","normal "+$(this).val());
        console.log($(this).val());
        $.post('private.php', { name: $(this).val(), function(data) {
        alert("Data Loaded: " + data); });
    });
});

private.php

$rows = $stmt->fetchAll(); 
<?php print_r($_POST); ?>

<h1>Memberlist</h1>
<div class="grid grid-pad">
    <?php foreach($rows as $row): ?>
        <div class="col-1-4">
            <div class="normal">
                <h1><?php echo htmlentities($row['username'], ENT_QUOTES, 'UTF-8'); ?></h1>
                <h2><?php echo htmlentities($row['email'], ENT_QUOTES, 'UTF-8'); ?></h2>
                <select name="dropdown">
                    <option value="primary">First pick</option>
                    <option value="secondary">Second pick</option>
                    <option value="not_interested">Not interested</option>
                </select>
            </div>
        </div>
        <?php// echo $row['id']; ?> <!-- htmlentities is not needed here because $row['id'] is always an integer --> 
    <?php endforeach; ?>
</div>

我的提醒

0 个答案:

没有答案