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>
    
    评论

报告相同问题?