<html>
<head>
<meta charset="utf-8"/>
<title>jsonp</title>
<script src="jquery.js"></script>
<script src="sample.js"></script>
</head>
<body>
<textarea id="artist"></textarea>
<input type="button" value="ken" onClick="sample()" />
<p id="memo"></p>
</body>
</html>
function sample() {
var a1=$("#artist").val();
alert(a1);
var urlx="http://yahoo.excale.net/yahoo?artist="+a1;
$.ajax({
type: 'GET',
url: urlx,
dataType: 'jsonp',
jsonpCallback: 'callback',
success: function(json){
var number = json.length;
var i,str;
str="noname";
if(number>0)str=json[0].yahoo;
$("#memo").html(str);
}
});
}
最終更新:2013年12月23日 09:42