检索与jQuery AJAX的数据,而无需在PHP刷新页面页面、数据、jQuery、AJAX

由网友(槍槍穩扎姑娘心°)分享简介:我已经试图阻止刷新页面上点击选择选项,但是当我停止刷新页面,然后数据无法获得。 I have try to stop refresh page on click on select option but when I stop refresh page then data can not get. 在这里code...

我已经试图阻止刷新页面上点击选择选项,但是当我停止刷新页面,然后数据无法获得。

I have try to stop refresh page on click on select option but when I stop refresh page then data can not get.

在这里code

echo "<form name='frmtopdevotees' method='post' action='topuser_load.php'>
                <h4>select month  <select id='seldrp' name='themonth' OnChange ='document.frmtopdevotees.submit()'>     


                        $optionsmonths
                </select> 
                <select name='topdevotees' id='seldrp' OnChange ='document.frmtopdevotees.submit()'>
                        <option value=10 $M10>Top 10</option>
                        <option value=20 $M20>Top 20</option>
                        <option value=50 $M50>Top 50</option>
                        <option value=100 $M100>Top 100</option>
                </select>   </h4>               
        </form>";
?>

<script>
    $('frmtopdevotees').submit(function (e) {
        e.preventDefault();
        return false;
    });

    $('themonth').onchange(function () {
        $.ajax({
            var value = $('themonth').val();
                    type: 'post',
            data: {
                topdevotees: topdevotees,
                themonth: themonth
            },
            url: "topuser_load.php?topdevotees=" + topdevotees + "&themonth=" + themonth,
            success: function (response) {
                $('themonth').append(response);

            }
        });
    });

</script>

当我删除的onChange ='document.frmtopdevotees.submit(),然后页面停止更新,但不是数据的变化。

when I remove Onchange = 'document.frmtopdevotees.submit()' then page stop to refresh but not data change.

推荐答案

修改名称在阿贾克斯ID

$('#seldrp').onchange(function(){
   ^     ^
// ajax here                          
});

和你有语法错误在阿贾克斯。

And you have syntax errors in ajax.

   var themonth = $('#seldrp').val();
   var topdevotee = $('#topdevotees').val();//topdevotess should be the id of 2nd select box.
   $.ajax({            
        type: 'post',
        data: {
            topdevotees: topdevotees,
            themonth: themonth
        },
        async:false,// this line for waiting for the ajax response.
        url: "topuser_load.php?topdevotees=" + topdevotees + "&themonth=" + themonth,
        success: function (response) {
            $('themonth').append(response);
            $('#frmtopdevotees').submit();

        }
    });
阅读全文

相关推荐

最新文章