0

I am developing a Phonegap application. I read RSS feeds from the website and display it in an appropriate way. The problem is that I get Access-Control-Allow-Origin problem . This is the code That I am using . forget about the success function I was just trying .

  $.ajax({
    url: "http://fixit.ps/n/pngo/?feed=rss2&cat=4",
    dataType: "xml",
    success: function(data) {
    console.log(data);
    var $xml = $(data),
        items = [];
    $xml.find("entry").each(function(i) {
        if (i === 30) return false;
        var $this = $(this);
        console.log($this);
        console.log($this.find("title").text());
        console.log($this.find("content").text());

    });
    }
    });
  • Look at this question. hope to be useful http://stackoverflow.com/questions/752319/cross-domain-ajax-request-with-jquery-php – Eyad Farra Jul 22 '13 at 23:57
  • I created a ticket in WP where asked to add this functionality https://core.trac.wordpress.org/ticket/50441#ticket Also in details of the ticket you may find a security concern. – Sergey Ponomarev Jun 20 '20 at 18:25

1 Answers1

0

edit your header.php or index.php file and add the following code at the top before echoing any response

<?php
header("Access-Control-Allow-Origin: *"); 
?>

or you can easily enable and disable Cross-Domain error using the plugin below:

https://github.com/jacopotarantino/WordPress-Cross-Domain-Plugin

BenMorel
  • 34,448
  • 50
  • 182
  • 322