Jump to content

Anyone understand what is going on in this script?


totalbeginner

Recommended Posts

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!DOCTYPE html>
<head id="Head1" runat="server">
<title></title>
<script type="text/javascript">
function TestId() {
WebService1.GetAppId(onSuccess, onFailure);
}
//situation 1
function onSuccess(result) {
alert(result);
}
//situation 2
//function onSuccess(result) {
// return result;
//}
function onFailure(result) {
alert("Error Invoking the Web Service...");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="scriptManager">
<Services>
<asp:ServiceReference
Path="~/WebService1.asmx" />
</Services>
</asp:ScriptManager>
<div>
<video id="localVideo" style="width: 300px; height: auto;" autoplay muted></video>
</div>
</form>
<script type="text/javascript">
TestId(); // This line is working in situation 1 (onSuccess method situation 1)
//BUT, WHEN I COMMENT METHOD IN SITUATON 1 AND UNCOMMENT SITUATION2 THEN LINE BELOW IS NOT WORKING
var a = TestId(); //THIS LINE IS NOT WORKING WHEN SITUATION2 IS ACTIVE
</script>
</body>
</html>
Link to comment
Share on other sites

well for one thing testId() doesn't have a return command so "var a" will always be undefined. add a return statement in testId() and start working from there.

function TestId() {     return WebService1.GetAppId(onSuccess, onFailure);}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...