开发者

PHP / jQuery Ajax / load xml within Ajax Processing Page

I'm stuck with some PHP Code that's called from a jQuery.Ajax call.

Basic code is this:

process.php:

$video_id = "u-KoTOhbn30";
$url = "http://gdata.youtube.com/feeds/api/videos/". $video_id;
$doc = simplexml_load_file($url);
$title = $doc->title;
// [sudo] Enter title into database //

Now, when I visit http://www.m开发者_如何学编程ydomain.com/process.php it works perfectly.

In my homepage is:

$.ajax({
  type: "POST",
  url: "process.php",
  data: dataString,
  success: function() {
     // do something
    });
  }
 });

Now, when the process.php gets called within this ajax process...nothing happens? it fails / ignores it. So how can I do it?? how can I read in an XML file within a page being called by Ajax?

Edit: Just to clarify... the Ajax call does process my page, its just that the $doc = simplexml_load_file($url); call doesn't work If i view the page manually simplexml works. When it's called via ajax it does nothing

Many thanks in advance


Add a parameter to success function to get returned data.

success: function(data) {
   alert(data); // returned content is stored in data and it is alerted here.
   // do something
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜