Not quite sure where to ask a javascript question. This is probably pretty easy, but I'm rather poor at javascript.
THIS WORKS (but has a hard-coded value of straightwire maestro):
<html>
<head>
<title>JSON Test</title>
</head>
<body>
<script type="text/javascript">
function ws_results(obj) {
alert(obj.ResultSet.totalResultsAvailable);
for (var i=0; i<obj.ResultSet.Result.length; i++) {
alert(obj.ResultSet.Result[i].Url); }
}
</script>
<script type="text/javascript" src="http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query='straightwire maestro'&output=json&callback=ws_results"></script>
<body> </body>
</html>
THIS DOES NOT WORK (what goes in after var string1 is ready to be run? what runs it? this part I don't understand.):
<html>
<head>
<title>JSON Test</title>
</head>
<body>
<script type="text/javascript">
function ws_results(obj) {
alert(obj.ResultSet.totalResultsAvailable);
for (var i=0; i<obj.ResultSet.Result.length; i++) {
alert(obj.ResultSet.Result[i].Url); }
}
function go1(data) {
alert('Does this work?');
var string1 ="http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query='" + data + "'&output=json&callback=ws_results";
alert(string1);
// add a line here to somehow execute the contents of string1 ? or what ?
}
</script>
<INPUT name=search1 id=search1 type="text" size=20><INPUT name=submit1 id=submit1 type="button"
onClick="go1(search1.value);" value="Go"><br />
</body>
</html>