weixin_33725272 2015-08-23 17:01 采纳率: 0%
浏览 17

jQuery Ajax请求失败

I'm new to web programming and I'm trying to select value for a selector box based on value selected in another selector box. Below is the jquery code snippet and php script for your reference. thanks for the help in advance.

jquery-ajax code

$(function(){
    $("#tier").change(function(){
    var formdata = {'tierval':document.getElementById("tier").value};
    alert("Selected Tier : "+document.getElementById("tier").value);
    $.ajax({
          type: "POST",
          url: "/includes/getplayers.php",
          data: formdata,
            success: function(data)
            {
                alert("called getplayers.php");
                $("#opp").empty();
                $("#opp").html(data);
            },
            error:function()
            {
                alert('ajax failed');
            }
        });
    });
});

php script:

<?php
if (isset($_POST['tierval']))
{
    $tier = $_POST['tierval'];
}
$query = "select PlayerID,First_Name from GOFTEL.PLAYER where TierID = $tier";
$result = mysqli_query($pconn, $query);
$row = mysqli_fetch_assoc($result);
while($row)
{
echo '<option value=\"$row[PlayerID]\" > $row[First_Name] </option>';
}   
/* free result set */
$result->free();
/* close connection */
$pconn->close();
?>
  • 写回答

2条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题
      • ¥15 win11如何运行geoserver
      • ¥15 审稿意见请教-用ERNIE进行小样本分类的对比实验问题
      • ¥15 gem5搭建arm v8
      • ¥15 安卓时间管理APP,怎么做
      • ¥15 这段有什么bug 为什么总报错
      • ¥15 Intel Realsense深度相机(D415/D435)拍摄梯子获取梯子点云