doumianfeng6979 2014-06-21 01:04
浏览 52

使用javascript加载函数传递变量不起作用

This is my code:

<script> 
    $(document).ready(function() {
        $('#status').on('submit',function(e) {

            $.ajax({
                url:'message.php',
                data:$(this).serialize(),
                type:'POST',
                success:function(data){
                console.log(data);
                $("#success").show().fadeOut(5000); //=== Show Success Message==
                $('#statusBox').val("");

                var passid = <?php echo $passid;?>;
                $("#loadViajquery").load(
                    "messages2.php",
                    { id: passid }
                );

                },
                error:function(data) {
                    $("#error").show().fadeOut(5000); //===Show Error Message====
                }
            });
        e.preventDefault(); //=== To Avoid Page Refresh and Fire the Event "Click"===
        });
    });
</script>

And then the PHP code on messages2.php

if (isset($_GET['id'])) {
    echo $_GET['id'];
}

This is not working, the problem is the variable (GET) is not being received. What could be the problem?

I tested removing the isset from the php script and just echoing static text and it worked, so the issue is definitely that the GET isn't being received, but I can't work out why.

This is the code that displays what is supposed to come from messages2.php

<script type="text/javascript">
    $(document).ready(function() {
        $("#loadViajquery").load("messages2.php");
    });      
</script>                         
<div id="loadViajquery">
</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
    • ¥15 linux驱动,linux应用,多线程
    • ¥20 我要一个分身加定位两个功能的安卓app
    • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
    • ¥15 IAR程序莫名变量多重定义
    • ¥15 (标签-UDP|关键词-client)
    • ¥15 关于库卡officelite无法与虚拟机通讯的问题
    • ¥15 目标检测项目无法读取视频
    • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
    • ¥100 求采集电商背景音乐的方法