TLD
TLD

Reputation: 8135

Read xml from php pages by Jquery

My XML file:

<?xml version="1.0"?>
 <xml>
  <weather>
   <location>Wonderland</location>
   <temp>20</temp>
  </weather>
 </xml>

My javascript:

<script type="text/javascript">
// <![CDATA[
$(document).ready(function(){

 $.ajax({

  type: "GET",

  url: "https://..../Weather.php",

  dataType: "xml",

   success: function(xml) {

    $(xml).find('weather').each(function(){

     var location = $(this).find("location").text();

     var temp = $(this).find("temp").text();

     $("#footer").append(temp+location);

      });

     }

     });

   });

  // ]]>

 </script>


Can somebody please show me where I was wrong? Thank you very much

Upvotes: 0

Views: 229

Answers (1)

Nate Higgins
Nate Higgins

Reputation: 2114

You could take a look at Origin http://localhost is not allowed by Access-Control-Allow-Origin.? - You may be running into cross-origin issues.

Upvotes: 1

Related Questions