Hi,
Javascript is not my forte, so excuse me if this is incredibly obvious:
I'm working on some code that creates a local database and table, retrieves an RSS feed and parses it and adds each item to the database. All is fine for the most part, yay. Except, I'm trying to add information from each item in the feed to a local database using the following code:
Here's the issue. The insert query is working, but it uses the same data every iteration. If I add alert() right before the title variable, it all works without a problem! WTF. I don't get it.
Help!
Thanks!
Javascript is not my forte, so excuse me if this is incredibly obvious:
I'm working on some code that creates a local database and table, retrieves an RSS feed and parses it and adds each item to the database. All is fine for the most part, yay. Except, I'm trying to add information from each item in the feed to a local database using the following code:
HTML:
$.ajax({
type: "GET",
url: feedurl,
dataType: "xml",
success: parseXml
});
function parseXml(xml){
$(xml).find("item").each(function(){
title = $(this).find("title").text();
description = $(this).find("description").text();
postype = $(this).find("postype").text();
category = $(this).find("category").text();
guid = $(this).find("guid").text();
postid = $(this).find("postid").text();
url = $(this).find("enclosure").attr('url');
db.transaction(function(tx) {
tx.executeSql('INSERT INTO Posts (title, description, postype, category, guid, postid) VALUES (?,?,?,?,?,?)', [title, description,postype,category,guid,postid]);
});
return true;
});
}
Here's the issue. The insert query is working, but it uses the same data every iteration. If I add alert() right before the title variable, it all works without a problem! WTF. I don't get it.
Help!
Thanks!