Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 实时搜索无法使用jquery处理附加的输入字段_Javascript_Php_Jquery_Ajax - Fatal编程技术网

Javascript 实时搜索无法使用jquery处理附加的输入字段

Javascript 实时搜索无法使用jquery处理附加的输入字段,javascript,php,jquery,ajax,Javascript,Php,Jquery,Ajax,我正在尝试将实时搜索放在附加的输入字段上,当单击“在添加更多字段按钮上执行操作”时,该字段将附加 这是我的Jquery代码 var max_fields = 100; //Maximum allowed input fields var wrapper = $(".wrapper"); //Input fields wrapper var add_button = $(".add_fields"); //Add button class or ID

我正在尝试将实时搜索放在附加的输入字段上,当单击“在添加更多字段按钮上执行操作”时,该字段将附加 这是我的Jquery代码

var max_fields = 100; //Maximum allowed input fields 
var wrapper    = $(".wrapper"); //Input fields wrapper
var add_button = $(".add_fields"); //Add button class or ID
var x = 1;
$(add_button).click(function(e){
    e.preventDefault();
    if(x < max_fields){ 
        x++; //input field increment and below is the input field form
        $(wrapper).append('<div><div class="row"><div class="col-sm-3"><input id="search" class="form-control" type="text" name="product[]" placeholder="Input Text Here" required /><div id="display"></div></div><a href="javascript:void(0);" class="remove_field">Remove</a></div></div>');
    }
});
$(wrapper).on("click",".remove_field", function(e){ 
    e.preventDefault();$(this).parent('div').remove(); x--; //input field decrement
})
在这里,我想对每个添加的输入字段执行搜索。 这是否可以通过Ajax对特定添加的字段执行搜索

我尝试的
搜索功能在未附加的其他输入字段上工作正常。

如果是HTML响应,请使用HTML功能

$(“#display”).html(html)

如果它只返回直接分配给该id的搜索结果


$('#search').val(html)

如果是HTML响应,请使用HTML函数

$(“#display”).html(html)

如果它只返回直接分配给该id的搜索结果


$('#search').val(html)

仅使用
$(“#display”).html(html)
@KUMAR感谢您的回答,但这不适用于meuse仅
$(“#display”).html(html)@KUMAR谢谢你的回答,但这对我不起作用
$("#search").keyup(function() {
   //Assigning search box value to javascript variable named as "name".
   var name = $('#search').val();
   //Validating, if "name" is empty.
   if (name == "") {
       //Assigning empty value to "display" div in "search.php" file.
       $("#display").html("");
   }
   //If name is not empty.
   else {
       //AJAX is called.
       $.ajax({
           //AJAX type is "Post".
           type: "POST",
           //Data will be sent to "ajax.php".
           url: "auto_fetch_product.php",
           //Data, that will be sent to "ajax.php".
           data: {
               //Assigning value of "name" into "search" variable.
               search: name
           },
           //If result found, this funtion will be called.
           success: function(html) {
               //Assigning result to "display" div in "search.php" file.
               $("#display").html(html).show();
           }
       });
   }});