2012-06-23 43 views
0

我爲得到RSS這個代碼從其他網站插入到數據的基礎上由JavaScript

gfeedfetcher.prototype._displayresult=function(feeds){ 
    var rssoutput=(this.itemcontainer=="<li>")? "<ul>\n" : "" 
    gfeedfetcher._sortarray(feeds, this.sortstring) 
    for (var i=0; i<feeds.length; i++){ 
     var itemtitle="<a href=\"" + feeds[i].link + "\" target=\"" + this.linktarget + "\" class=\"titlefield\">" + feeds[i].title + "</a>" 
     var itemlabel=/label/i.test(this.showoptions)? '<span class="labelfield">['+this.feeds[i].ddlabel+']</span>' : " " 
     var itemdate=gfeedfetcher._formatdate(feeds[i].publishedDate, this.showoptions) 
     var itemdescription=/description/i.test(this.showoptions)? "<br />"+feeds[i].content : /snippet/i.test(this.showoptions)? "<br />"+feeds[i].contentSnippet : "" 
     rssoutput+=this.itemcontainer + itemtitle + " " + itemlabel + " " + itemdate + "\n" + itemdescription + this.itemcontainer.replace("<", "</") + "\n\n" 
    } 
    rssoutput+=(this.itemcontainer=="<li>")? "</ul>" : "" 
    this.feedcontainer.innerHTML=rssoutput 
} 

然後我需要插入標題和新的臨客上表中的數據的基礎這個鱈魚由JavaScript

+1

見這太問題,可能與你想達到什麼相似:http://stackoverflow.com/questions/4139532/insert-data-into-mysql-database-using-javascript- ajax –

+0

不,我有var feeds [i] .link,feeds [i] .title,我不會讓sql插入到數據庫中 –

+0

您還沒有閱讀整篇文章和鏈接的答案部分I給你。你有類似的問題,試圖用JS/jQuery/Ajax處理數據庫數據插入 –

回答

0

Ajax請求的例子:

$.ajax({ 
    type: "POST", // or GET 
    url: "databasehandler.php", 
    data: { feedtitle: "Some Title", feedlink: "Some URL" } 
}).done(function(msg) { 
    alert("Data Saved: " + msg); 
}); 

-

databaseh andler.php

<?php 

    print_r($_POST); 

    // 
    // Do your database handles here. 
    // Connect, Query, then return success/failure status 

?>