I am using JavaScript rather than JQuery to call a web service. But the problem is I keep getting undefined back as a result. I have done some searching for this but all I seem to find is JQuery related post instead of JavaScript related.
I know that the webservice itself gets the right inputs and returns the right output. I have tested it on its own.
function RegisterFunction() {
//Calling the web method
//<-- Some code -->
data = Food_Calorie_Calculator.WebService1.Register(name, password, RegisterFunctionSuccessCallback);
}
function RegisterFunctionSuccessCallback(data) {
document.getElementById("ResultLabel") = data.;
}
Here is my script manager:
<asp:ScriptManager ID="ScriptManger1" runat="Server">
<Services>
<asp:ServiceReference Path="~/RegisterService.asmx" />
</Services>
</asp:ScriptManager>
remove data. from your code
document.getElementById("ResultLabel") = data;
The problem is was sintax error.
instead of:
document.getElementById("ResultLabel") = data;
it should have been:
document.getElementById('ResultLabel').innerHTML = data;
Note the ' ' instead of " ", as well as the .innerHTML
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.