dongzong3053 2014-01-14 01:33
浏览 36

AJAX表单发送数据,PHP表单没有收到它

I had this working earlier, but now it doesn't seem to want to pick up the data. It's possible something changed when I was trying to make it stop refreshing the page.

The form submits, but only for certain links. However the data gets sent across as normal. It's extremely strange.

This is the page the data is being sent to. Right now it just accepts the data and posts it for testing. "Text" shows but nothing else.

<?php

$ship_id = $_POST['transfer_ship'];
$char_id = $_POST['transfer_character'];
$pos_id = $_POST['transfer_position'];
$requested_by = $_POST['transfer_player'];

echo 'Success';
echo $ship_id;
echo $char_id;
echo $requested_by;
echo $pos_id;
echo $char_owner;
echo 'Text';

This is the form it's being sent from. It's part of a PHP UL series that's running. For the first result, the jQuery fires, I get the "Success" alert. For any of the other li links the data apparently gets sent (I use the F12 dev tools in Chrome, under Network, to see the header) but the page above either doesn't receive it or doesn't do anything with it.

jQuery:

<script type="text/javascript" src="../fancybox/jquery.fancybox.js?v=2.1.3"></script>
<script type="text/javascript">
$(document).ready(function() {
    $(".fancybox").fancybox();
});
</script>
<script src="http://malsup.github.com/jquery.form.js"></script> 
<script> 
    // wait for the DOM to be loaded 
    $(document).ready(function() { 
        // bind 'myForm' and provide a simple callback function 
        $('#transfer').ajaxForm(function() { 
            alert('Success!');
        }); 
    }); 
</script> 

Form and UL:

<ul>
<?php
        while(list($key, $val) = each ($arrayresult))
        {

            echo '<a href="#inline' .$val. '" class="fancybox"><li style="padding: 2px; margin: 0px; list-style: none;">';
            echo '<img src="../images/profilepics/'.$charpic.'" style="float: right; padding-left: 10px; width: 40px;" />';
            echo '<h2>'.$val.' Position</h2>';
            echo '<p>Click here to apply for this position.</p>';
            echo '</li></a>';

            echo '<div id="inline' .$val. '" style="display:none;">';
            echo '<h1>Request Character Transfer</h1>';
            echo '<hr>';
            echo '<form id="transfer" action="TransferRequest.php" method="post">';
            echo '<label for="transfer_character">Character to Transfer</label>';
            echo '<select id="transfer_character" name="transfer_character">';
            echo '<option value="">Select Character</option>';

            $request_character_query = "SELECT * FROM character_database WHERE character_active ='1' AND user_id = $user_id ORDER BY character_firstname DESC";
            $request_character_result = mysqli_query($mysqli, $request_character_query);

            /*** loop over the results ***/
            foreach($request_character_result as $charrow)
            {
              /*** create the options ***/
              echo '<option value="'.$charrow['character_id'].'">'. $charrow['character_firstname'] . " " . $charrow['character_surname'] . '</option>'."
";
            }
            echo '</select>';
            echo '<p>Applying for the '.$val.' position on the '.$shipname.'</p>';
            echo '<p>If this is correct, please submit below</p>';
            echo '<input type="hidden" value="'.$val.'" name="transfer_position">';
            echo '<input type="hidden" value="'.$ship_id.'" name="transfer_ship">';
            echo '<input type="hidden" value="'.$user_id.'" name="transfer_player">';
            echo '<input value="Submit Request" type="submit" class="styled">';
            echo '</form>';
            echo '</div>';
        }
    ?>
</ul>
  • 写回答

1条回答 默认 最新

  • doulai1910 2014-01-14 12:54
    关注

    I figured it out! I have my htaccess file removing the .php extension, but I had .php on the redirect link for ajax. So it was hitting the .php page then redirecting WITHOUT the POST data.

    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line