weixin_33675507 2014-07-22 02:58 采纳率: 0%
浏览 9

jQuery ajax json网址

I've given up on trying to accomplish my intended objective! I have jquery/ajax code that is as simple as I can get it using web and library. I've been working on this several weeks; thank goodness I'm retired or I'd be without a job! I have never seen so much code that doesn't work on the net today. Most examples don't bother to show the url used in the ajax call! Anyway I've loaded up an htm file and a txt file. Please find something wrong, I am tired of looking, thx.

htm file

<!DOCTYPE html>
<HTML>
<HEAD> 
<title>testing</title>

<script src="../jquery-1.11.1.min.js"></script>
<script type="text/javascript">
$("button").click(function(){
    $.ajax({url:"test.txt"})
    .success (function(result){ $("#comdisplay").html(result); });
});
</script>

</HEAD>
<BODY>

<center><button><h3>Click</h3></button></center>

<div id='comdisplay'></div>

</body>
</html>

txt file

<h2>howdy folks</h2>

That's it, Thanks

  • 写回答

5条回答 默认 最新

  • weixin_33724059 2014-07-22 03:02
    关注
    <script type="text/javascript">
    $(function(){
    $("button").click(function(){
        $.ajax({url:"test.txt"})
        .success (function(result){ $("#comdisplay").html(result); });
    });
    })
    </script>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分