Code for jQuery: GET into SPAN html?
$("#ShowRating").html($.get(url));
This is not working, in fact firebug doesn't even开发者_C百科 show any headers... what am I doing wrong here?
get doesn't return what you are getting (it is asynchronous). Try using load instead:
$("#ShowRating").load(url);
As the others say, 'load' is a more direct way of doing what you are trying to do. But to show you a little more about how $.get works and why it isn't working in your example, here is how you would do it with $.get:
$.get(url, function(data) {
$("#ShowRating").html(data);
});
Since $.get is asynchronous, the loading of the webpage did not wait for the GET request to return to fill in the data in the page. Instead, you pass in the callback function to handle the request result when the GET request actually completes.
Try using $.load()
instead:
$("#ShowRating").load("somepage.html");
Keep in mind too that Internet Explorer caches this request, so if you need to make this call again, it would be best to append some random characters on as a parameter.
精彩评论