I’d like make this effection.
Firstly, there have some tag links in my main page. click each one, post value to 2.php with jquery.ajax and turn back value in div#result.
2.php have a search box. when search something in it. the result data will still show in the div#result.
my problem is: I know if I will do jqeury ajax in the b.php, I shall write the jqeury code in the first success part. but this only can control one time, when I continue search in the search box, the jquery not work. I think I met a loop problem. How to solve it?
1.php
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.click').click(function(){
var value1 = $(this).text();
$.ajax({
url: "2.php",
dataType: "html",
type: 'POST',
data: "data=" + value1,
success: function(data){
$("#result").html(data);
$('#search').click(function(){
var value = $('#search1').val();
$.ajax({
url: "2.php",
dataType: "html",
type: 'POST',
data: "data=" + value,
success: function(data){
$("#result").html(data);
}
});
});
}
});
});
});
</script>
<a rel="aa" class="click">aa</a>
<a rel="aa" class="click">bb</a>
<div id="result"></div>
2.php
<?php
echo $_POST['data'];
?>
<form name="form">
<input type="text" value="" id="search1">
<a name="nfSearch" id="search">search</a>
</form>