Please forgive me if this has already been asked. I am not sure what key words to use to look this question up. In my code I make a webservice call and pass it's result to a function.
stockService.GetVideoGet(P.Guid.substring(1), ResponceType).onResult = LoadVideoPlayer;
In the function LoadVideoPlayer, I look through the results and build a custom video player. If the video doesnt exist then I do an alert saying this video has been disabled. Whatr I would like to do is .onResult pass the function LoadVideoPlayer function the variable P.Guid so that if the video doesnt exist I can use that to remove out the player code.
Here is what I have so far.
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.
}}
Is it possible to do something like this
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.'
}}
Figured it out. I had to use the bind and switch my functions variables.
stockService.GetVideoGet(P.Guid.substring(1), ResponceType).onResult = LoadVideoPlayer.bind(this, P.Guid);
LoadVideoPlayer = function (PG, result) {
if (result.StatusMessage.toString() === "Success") {
//Build Player using the result.
} else {
alert(result.StatusMessage.toString());
alert(PG);
}}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.