Javascript 如何使用Jquery重新加载特定的div?

Javascript 如何使用Jquery重新加载特定的div?,javascript,jquery,html,css,ruby-on-rails,Javascript,Jquery,Html,Css,Ruby On Rails,在rails应用程序中,我有一个任务栏。选中复选框时,我需要过滤任务栏中的内容。为此,我必须重新加载一个特定的div 我尝试了以下方法 $("input:checkbox").change(function(){ '<%@final_tasks= @final_tasks.find(142)%>' $("#task_content").reload(); }); $(“输入:复选框”).change(函数(){ '' $(“#任务内容”).reload(); }); 这

在rails应用程序中,我有一个任务栏。选中复选框时,我需要过滤任务栏中的内容。为此,我必须重新加载一个特定的div

我尝试了以下方法

$("input:checkbox").change(function(){ 
  '<%@final_tasks= @final_tasks.find(142)%>'
  $("#task_content").reload();
});
$(“输入:复选框”).change(函数(){
''
$(“#任务内容”).reload();
});

这里的
task\u content
是div类名。但我的代码不起作用。请帮助我。

您必须向控制器发送某种GET请求以获取新信息

$("input:checkbox").change(function(){
  $.get('/your_controller/task_content', function(data) {
    $("#task_content").html(data.final_tasks);
  }
});
因此,您的控制器将有一些查找操作。我们称之为
task\u content

def task_content
  @final_tasks= @final_tasks.find(142)
  # though I assume you want this to be more dynamic so this is just an example
  respond_to do |format|
    format.json {render json: {final_tasks: @final_tasks} }
  end
end
然后确保在
路线中添加该路线。rb

 get 'your_controller/task_content'     => 'your_controller#task_content'

您必须向控制器发送某种GET请求以获取新信息

$("input:checkbox").change(function(){
  $.get('/your_controller/task_content', function(data) {
    $("#task_content").html(data.final_tasks);
  }
});
因此,您的控制器将有一些查找操作。我们称之为
task\u content

def task_content
  @final_tasks= @final_tasks.find(142)
  # though I assume you want this to be more dynamic so this is just an example
  respond_to do |format|
    format.json {render json: {final_tasks: @final_tasks} }
  end
end
然后确保在
路线中添加该路线。rb

 get 'your_controller/task_content'     => 'your_controller#task_content'

您必须向控制器发送某种GET请求以获取新信息

$("input:checkbox").change(function(){
  $.get('/your_controller/task_content', function(data) {
    $("#task_content").html(data.final_tasks);
  }
});
因此,您的控制器将有一些查找操作。我们称之为
task\u content

def task_content
  @final_tasks= @final_tasks.find(142)
  # though I assume you want this to be more dynamic so this is just an example
  respond_to do |format|
    format.json {render json: {final_tasks: @final_tasks} }
  end
end
然后确保在
路线中添加该路线。rb

 get 'your_controller/task_content'     => 'your_controller#task_content'

您必须向控制器发送某种GET请求以获取新信息

$("input:checkbox").change(function(){
  $.get('/your_controller/task_content', function(data) {
    $("#task_content").html(data.final_tasks);
  }
});
因此,您的控制器将有一些查找操作。我们称之为
task\u content

def task_content
  @final_tasks= @final_tasks.find(142)
  # though I assume you want this to be more dynamic so this is just an example
  respond_to do |format|
    format.json {render json: {final_tasks: @final_tasks} }
  end
end
然后确保在
路线中添加该路线。rb

 get 'your_controller/task_content'     => 'your_controller#task_content'
像这样试试

function get_data(val)
{
   $.post('path_fro_data.php',{'value':val},
           function(data) 
              {
                $("#div_task").html(data);
              }
          );

}
在html中

<input type="checkbox" id="check_1" name="check_1" value="1" onchange="get_data(this.value);"/>
<input type="checkbox" id="check_2" name="check_2" value="2" onchange="get_data(this.value);"/>

在服务器脚本(例如examle.php页面)中,从与发送的数据对应的数据库中获取数据。

像这样尝试

function get_data(val)
{
   $.post('path_fro_data.php',{'value':val},
           function(data) 
              {
                $("#div_task").html(data);
              }
          );

}
在html中

<input type="checkbox" id="check_1" name="check_1" value="1" onchange="get_data(this.value);"/>
<input type="checkbox" id="check_2" name="check_2" value="2" onchange="get_data(this.value);"/>

在服务器脚本(例如examle.php页面)中,从与发送的数据对应的数据库中获取数据。

像这样尝试

function get_data(val)
{
   $.post('path_fro_data.php',{'value':val},
           function(data) 
              {
                $("#div_task").html(data);
              }
          );

}
在html中

<input type="checkbox" id="check_1" name="check_1" value="1" onchange="get_data(this.value);"/>
<input type="checkbox" id="check_2" name="check_2" value="2" onchange="get_data(this.value);"/>

在服务器脚本(例如examle.php页面)中,从与发送的数据对应的数据库中获取数据。

像这样尝试

function get_data(val)
{
   $.post('path_fro_data.php',{'value':val},
           function(data) 
              {
                $("#div_task").html(data);
              }
          );

}
在html中

<input type="checkbox" id="check_1" name="check_1" value="1" onchange="get_data(this.value);"/>
<input type="checkbox" id="check_2" name="check_2" value="2" onchange="get_data(this.value);"/>


在服务器脚本(例如examle.php页面)中,从数据库中获取与发送的数据相对应的数据。

创建了一个名为refresh的插件,因此无论何时需要刷新内容,都可以调用该函数。请检查下面的代码

$.fn.refresh = function(options) {

    var options = {
        contentURL : 'xxx.html'
    };
    options = $.extend({},options);
    return this.each(function() {
        var obj = $(this);
        setTimeout( function() {
            obj.fadeOut('slow').load(options.contentURL).fadeIn('slow');      
        }, 2000);            
    });

};
$('#task_content').refresh();

创建了一个名为refresh的插件,因此无论何时需要刷新内容,都可以调用该函数。请检查下面的代码

$.fn.refresh = function(options) {

    var options = {
        contentURL : 'xxx.html'
    };
    options = $.extend({},options);
    return this.each(function() {
        var obj = $(this);
        setTimeout( function() {
            obj.fadeOut('slow').load(options.contentURL).fadeIn('slow');      
        }, 2000);            
    });

};
$('#task_content').refresh();

创建了一个名为refresh的插件,因此无论何时需要刷新内容,都可以调用该函数。请检查下面的代码

$.fn.refresh = function(options) {

    var options = {
        contentURL : 'xxx.html'
    };
    options = $.extend({},options);
    return this.each(function() {
        var obj = $(this);
        setTimeout( function() {
            obj.fadeOut('slow').load(options.contentURL).fadeIn('slow');      
        }, 2000);            
    });

};
$('#task_content').refresh();

创建了一个名为refresh的插件,因此无论何时需要刷新内容,都可以调用该函数。请检查下面的代码

$.fn.refresh = function(options) {

    var options = {
        contentURL : 'xxx.html'
    };
    options = $.extend({},options);
    return this.each(function() {
        var obj = $(this);
        setTimeout( function() {
            obj.fadeOut('slow').load(options.contentURL).fadeIn('slow');      
        }, 2000);            
    });

};
$('#task_content').refresh();

“不工作”不是很有描述性,是吗?是的。我不熟悉jquery,“不工作”不是很有描述性,是吗?是的。我不熟悉jquery,“不工作”不是很有描述性,是吗?是的。我不熟悉jquery,“不工作”不是很有描述性,是吗?是的。我是JQUERI的新手我会试试这个让你知道我会试试这个让你知道我会试试这个让你知道我会试试这个让你知道