weixin_33736832 2013-11-15 10:06 采纳率: 0%
浏览 59

jQuery和AJAX用于txt文件

This is the script I have

<div id="result"></div>
<script src="jquery-1.10.2.min.js"></script>
<script>
$('#year li').click(function() {
    var text = $(this).text();
    //alert('text is ' + text);
    $.post("B.php",
    {
    text: text,

      } );  
    event.preventDefault() ;
  });
</script>

it executes a php script when a list item is clicked. The script B.php creates a few txt files. lets call one of them ddd.txt. Now I want to load the contents of the file ddd.txt onto the div with id result when the click has been made. Can someone help me with it?

  • 写回答

4条回答 默认 最新

  • perhaps? 2013-11-15 10:11
    关注
    $.post("B.php",{ text: text}, function(data){
        $('#result').text(data);
    }); 
    

    Or if jQuery >= 1.5:

    $.post("B.php",{ text: text}).done(function(data){
        $('#result').text(data);
    }).fail(function(){
        console.log('something went wrong', arguments);
    }); 
    
    评论

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题