javascript or jquery simple code
I have a problem. I don't know JavaScript or jQuery; only HTML, CSS, PHP, and design. I need a simple jQuery function, but I don't know how to do it.
I nee开发者_JS百科d to make a call to the following webservice:
- http://vkontakte.ru/share.php?act=count&url=http://viberieto.ru/
This function returns a number near ')'. I need to display this number in <div id="count">
.
How do I do that? Can you help me?
Because of restriction due to crossdomain policy you probably need get the data through jsonp. Luckily this is easily done with jQuery.
$.getScript("http://vkontakte.ru/share.php?act=count&url=http://viberieto.ru/");
This will create a new script tag containing the code returned by the webservice. To handle the response you'll need to create a object structure like the one from the url:
var VK = {
Share: {
count: function(arg1, arg2) {
// Insert the value into the div
$('#count').html(arg2);
}
}
};
VK
Edit: Fixed typo
精彩评论