Ei muokkausyhteenvetoa |
Ei muokkausyhteenvetoa |
||
| Rivi 22: | Rivi 22: | ||
var classes = jQuery( this ).attr('class').split(' '); | var classes = jQuery( this ).attr('class').split(' '); | ||
select.find( 'option' ).each( function() { | |||
var page = jQuery( this ).text(); | |||
searchImg = "action=query&prop=imageinfo&iiprop=url&format=json&titles=" + encodeURIComponent( page ); | |||
jQuery.ajax({ | |||
type: 'POST', | |||
url: 'https://www.jarviwiki.fi/w/api.php', | |||
data: searchImg, | |||
dataType: 'jsonp', | |||
success: function( reqImg ) { | |||
console.log( reqImg ); | |||
for ( var i in reqImg.query.pages ) { | |||
if ( typeof reqImg.query.pages[i].imageinfo != 'undefined' ) { | |||
console.log( reqImg.query.pages[i].imageinfo[0].url ); | |||
} | |||
break; | |||
} | |||
}, | |||
error: function(err) { | |||
console.log(err); | |||
imgUrlLoaded; | |||
} | |||
}); | |||
//output += ''; | //output += ''; | ||


