duanpu1963 2012-05-09 18:41
浏览 61
已采纳

Jquery OnChange触发但没有返回数据

I have posted this a few times looking for some help, I cant seem to work out why i dont get any data from my dynamic drop down but i do from the 2 static fields. I did get some answers but mainly saying that i need to sort out the security, which i hope to learn next before anything is live online, everything looks good in Firebug including the trace for the http request, i think its a problem with the query i am trying to run, i will post this again and see if anyone can help me out before i address the security flaws.

Thanks alot for helping me out.

first is html, the subcategory is the problem, all items are stored in a javascript array and works fine, just not the query

<select name="Category" id="Category" 
onchange="javascript: dropdownlist(this.options[this.selectedIndex].value);">
<option value="">Select Category</option>

<select name="subcategory" id="subcategory">
<option value="">Select Sub-Category</option>
</select>

<script>

$(function() {
  $('#subcategory').change(function() {
        $('#subcategory').load('results.php', {value: $(this).val()});
  });
});

</script>

 $category=$_POST['Category'];
 $subcategory=$_POST['Subcategory'];
 $destination=$_POST['Destination'];


 $result = mysql_query("SELECT * FROM travel WHERE Category='$category' 
 AND Subcategory='$subcategory' AND Destination='$destination'")
 or die(mysql_error());


 $row = mysql_fetch_assoc( $result ) ;

echo to table (not posted as is working ok)

  • 写回答

2条回答 默认 最新

  • duanbei7005 2012-05-09 19:04
    关注

    Where to even start? Your field name is 'subcategory'. You pass 'value' to results.php and you're attempting to retrieve 'Subcategory' form the $_POST array. You need to line all these names up.

    I'm not sure whether the PHP there is the code for results.php or for whatever script the form is posted to, or are they the same? Regardless, whatever results.php needs, you need to include in the data you pass to load. For example, since you currently use 'value', you'd retrieve that via $_POST['value'], not $_POST['Subcategory'].

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

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