2

我正在使用以下函数从“PlayListJSON.aspx”加载歌曲播放列表,但似乎有些错误,evrytime OnFailure 被调用,我无法进一步调试它。任何帮助都将是真正的 gr8。

Player.prototype.loadPlaylist = function(playlistId, play) {
  req = new Ajax.Request('/PlaylistJSON.aspx?id=' + playlistId, {
    method: 'GET',
    onSuccess: function(transport, json) {
      eval(transport.responseText);

      player.setPlaylist(playlist.tracklist, playlist.title, playlistId);
      player.firstTrack();

      if (play) player.playSong();
    },
    onFailure: function() {
      //error
    }
  });
}
4

3 回答 3

1

通常,当您调用的页面由于某种原因无法访问时,会调用 OnFailure。

您确定 URL /PlaylistJSON.aspx有效吗?


您是否尝试过传递参数参数而不是将它们指定为 url 的一部分?

req = new Ajax.Request('/PlaylistJSON.aspx', 
    { 

        method: 'GET',    
        parameters:  {
                     'id': playlistId
                     },
        onSuccess: function(transport,json){                                                                                    

            eval(transport.responseText);                              

            player.setPlaylist(playlist.tracklist,playlist.title, playlistId);
            player.firstTrack();

            if (play)
                player.playSong();  

         },
         onFailure: function() {
           //error

         }
     });
于 2008-10-25T12:11:19.513 回答
1

If you are developing in windows install Fiddler. With Fiddler you will be able to see exactly what request is doing the Ajax call and what response comes from the server. This way you will know if the url is right, or if the server is responding some status code different from 200/OK.

于 2008-12-11T11:43:46.913 回答
0

是的,Page PlayListJSon.aspx 位于根目录中。

于 2008-10-25T12:12:51.193 回答