Skip to content

Instantly share code, notes, and snippets.

@ahappyforest
Created January 28, 2013 11:36
Show Gist options
  • Save ahappyforest/4654821 to your computer and use it in GitHub Desktop.
Save ahappyforest/4654821 to your computer and use it in GitHub Desktop.
<html>
<head><title>Hello World</title></head>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js'></script>
<body>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
url : "http://www.xkcd.com/info.0.json",
ansy : true,
success : function(connent){
alert(connent);
var obj = eval('('+connent+')');
$("body").html(obj.img);
},
});
});
</script>
</body>
</html>
@creamidea
Copy link

貌似ajax的success方法这么使用的:(你试试啊),成功了告诉我啊:)

<title>Hello World</title> <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js'></script> <script type="text/javascript"> $(document).ready(function(){ $.ajax({ type:"GET", url : "http://www.xkcd.com/info.0.json", ansy : true }).success(function(connent){ alert(connent); var obj = eval('('+connent+')'); $("body").html(obj.img); }); }); </script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment