Php 用javascript插入数据库

Php 用javascript插入数据库,php,javascript,Php,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++){

我有这个从其他站点获取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
}
gfeedfetcher.prototype.\u displayresult=函数(提要){
var rssoutput=(this.itemcontainer==“
  • ”)“
      \n”:” gfeedfetcher.\u sortarray(feed,this.sortstring)
      对于(var i=0;iajax请求示例:

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

      databasehandler.php

      <?php
      
           print_r($_POST);
      
           // 
           // Do your database handles here.
           // Connect, Query, then return success/failure status
      
      ?>
      
      
      
      请看这个问题,可能与您想要实现的目标类似:不,不,我有var提要[i]。链接,提要[i].title,我不会让sql在数据库中插入它。您还没有阅读整篇文章和我给您的链接的答案部分。您遇到了类似的问题,试图用JS/jQuery/AjaxUse jQuery+ajax处理数据库数据插入,后端有一个由ajax请求调用的php数据库处理程序。请参阅下面我答案中的示例。