通过 JavaScript 插入到数据库中


insert into data base by javascript

>我有这个代码从其他站点获取RSS

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 的鳕鱼

ajax 请求的示例:

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

--

数据库处理程序.php

<?php
     print_r($_POST);
     // 
     // Do your database handles here.
     // Connect, Query, then return success/failure status
?>