JavaScript:如何将变量传递给webservice的onResult函数?

时间:2019-03-13 03:44:59

标签: javascript variables

请原谅我。我不确定要使用什么关键词来查找这个问题。在我的代码中,我进行了网络服务调用,并将结果传递给函数。

stockService.GetVideoGet(P.Guid.substring(1), ResponceType).onResult = LoadVideoPlayer;

在功能LoadVideoPlayer中,我浏览结果并构建一个自定义视频播放器。如果该视频不存在,那么我会提醒您该视频已被禁用。我想做的是.onResult传递函数LoadVideoPlayer函数的变量P.Guid,以便如果视频不存在,我可以用它删除播放器代码。

这是我到目前为止所拥有的。

    LoadVideoPlayer = function (result) {
    if (result.StatusMessage.toString() === "Success") {
        //Build Player using the result information. In the result information is the player ID and I use that ID to refrence the div on the htmlplage to know were the player should be built.
    } else {
        alert(result.StatusMessage.toString());
        //If the player is disabled I dont get a player ID so my player div doesnt know what to do. I am unable to change the webservice results. So I want to try to pass in the P.Guid and use that as the player ID.
    }}

是否可以做这样的事情

        LoadVideoPlayer = function (result, P) {
    if (result.StatusMessage.toString() === "Success") {
        //Build Player using the result information. In the result information is the player ID and I use that ID to refrence the div on the htmlplage to know were the player should be built.
    } else {
        alert(result.StatusMessage.toString());
        $('#'+P.Guid).innerHTML = 'This player has been disabled.'
    }}

0 个答案:

没有答案