Reputation: 1
what I'm trying to do is simply catch some data from a file and insert to another file's (the one that that the js is in) div. It won't work and I can't seem to find the failure in here. I googled for it, but it gave me no answers. Any suggestions?
jQuery:
$(document).ready(function(){
$("li#twitter-widget a").click(function(event){
$('<span class="loading">Lade Inhalte</span>').appendTo("div#news-widget");
$.get("widgets/twitter.widget", function(data){
$(data).find("div.twtr-doc").appendTo("div#news-widget");
alert( data );
$('span.loading').remove();
});
});
});
The twitter.widget
http://nopaste.info/1a6c866a15.html
The HTML that I want the data to be inserted to
http://nopaste.info/435800b8f8.html
The Problem
alert(data) doesn't put out anything.
Upvotes: 0
Views: 109
Reputation: 1
You're making an ajax call to an html page? Is that page statgic or a re you trying to access one of the services in that page? Have you looked into using load instead? That will get you sections of an html I believe, wich can then be assigned to a var and appended.
Upvotes: 0
Reputation: 14777
jQuery injects scripts retrieved via AJAX into the DOM and removes them from the "data". Since your "twitter.widget" is nothing more than two script elements, your "data" is going to be empty.
You might want to use $.getScript instead.
Upvotes: 1