admin管理员组文章数量:1414621
Hie Everyone! In PHP page1 my code is here..
<html>
.
...
<select id="customer">...</select>
..
....
<div id="show"></div>
//and Java script function (ajax call)
<script>
$('#customer').change(function(){
var Id = $(this).val();
$.ajax({
type: "GET",
url: "page2.php",
data: "ID="+id,
success: function( data ) {
document.getElementById("show").innerHTML = data;
}
});
});
</script>
</html>
In php page2 as code..
<?php
$ID=$_GET['ID'];
...
//db connection code
..
$sql="select * from Table1 where id='$ID'";
//result code..
//while loop..
//echo something..
// all working without error..
?>
So, when I was trying to do this.It does not showing the success data or may be Ajax function not work.I had check with alert(data); but does not Alert anything. please help.
Hie Everyone! In PHP page1 my code is here..
<html>
.
...
<select id="customer">...</select>
..
....
<div id="show"></div>
//and Java script function (ajax call)
<script>
$('#customer').change(function(){
var Id = $(this).val();
$.ajax({
type: "GET",
url: "page2.php",
data: "ID="+id,
success: function( data ) {
document.getElementById("show").innerHTML = data;
}
});
});
</script>
</html>
In php page2 as code..
<?php
$ID=$_GET['ID'];
...
//db connection code
..
$sql="select * from Table1 where id='$ID'";
//result code..
//while loop..
//echo something..
// all working without error..
?>
So, when I was trying to do this.It does not showing the success data or may be Ajax function not work.I had check with alert(data); but does not Alert anything. please help.
Share Improve this question asked Mar 17, 2015 at 9:16 PratikshaPratiksha 11 gold badge1 silver badge5 bronze badges 5-
what output of url
page2.php?ID=[some id]
? – bekt Commented Mar 17, 2015 at 9:21 - data: "ID="+id, var Id = $(this).val(); - try with uppercase, fix this: data: "ID="+Id - uppercase 'I'. – sinisake Commented Mar 17, 2015 at 9:21
- you will give echo infront of the $ID variable <?php echo $ID=$_GET['ID']; ... //db connection code .. $sql="select * from Table1 where id='$ID'"; //result code.. //while loop.. //echo something.. // all working without error.. ?> – Vetrivel Commented Mar 17, 2015 at 9:21
- Sorry guys..But id and Id problem is just here when I paste my code. It all right in my original page. – Pratiksha Commented Mar 17, 2015 at 9:33
- Its still not working – Pratiksha Commented Mar 17, 2015 at 9:33
1 Answer
Reset to default 2You will give echo infront of the $get_id variable. But you will make sure only one echo in the page2.php page.
<?php
echo $get_id=$_GET['pass_id'];
...
//db connection code
..
$sql="select * from Table1 where id='$get_id'";
//result code..
//while loop..
//echo something..
// all working without error..
?>
Then in page1.php check your ajax response. using alert function.
<script>
$('#customer').change(function(){
var id = $(this).val();
$.ajax({
type: "GET",
url: "page2.php",
data: "pass_id="+id,
success: function( data ) {
alert(data);
document.getElementById("show").innerHTML = data;
}
});
});
</script>
本文标签: javascriptajax function on change dropdown ValueStack Overflow
版权声明:本文标题:javascript - ajax function on change dropdown Value - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745184506a2646619.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论