Need help with javascript and data from web service
JavaScript
3
Posts
2
Posters
2
Views
1
Watching
-
Hi! I’m not so familiar with java script, i got the call to the web service working but how do i store the value from the web service in var result?, HelloWorld will be replaced with another method that returns different data depending on the input.
<script type="text/javascript"> $(document).ready(function () { var result; HelloWorld(); // How do if store the data in result before the next line of code is executed? //doSomething with the result }); $(document).ready(function () { var result2; HelloWorld(); // How do if store the data in result2 before the next line of code is executed? // doSomething with the result }); function HelloWorld() { Pagesettings.test(HelloWorldCallback); } function HelloWorldCallback(result) { alert(result); } </script>
Can someone help me, thanks!
-
Hi! I’m not so familiar with java script, i got the call to the web service working but how do i store the value from the web service in var result?, HelloWorld will be replaced with another method that returns different data depending on the input.
<script type="text/javascript"> $(document).ready(function () { var result; HelloWorld(); // How do if store the data in result before the next line of code is executed? //doSomething with the result }); $(document).ready(function () { var result2; HelloWorld(); // How do if store the data in result2 before the next line of code is executed? // doSomething with the result }); function HelloWorld() { Pagesettings.test(HelloWorldCallback); } function HelloWorldCallback(result) { alert(result); } </script>
Can someone help me, thanks!
Include jquery first then follow:
<script type="text/javascript"> $(document).ready(function () { PageMethods.MyMethod(HelloWorldCallback); }); function HelloWorldCallback(result) { alert(result); } </script>
.cs file
[WebMethod]
public static string MyMethod()
{return "Hello "; }
-
Include jquery first then follow:
<script type="text/javascript"> $(document).ready(function () { PageMethods.MyMethod(HelloWorldCallback); }); function HelloWorldCallback(result) { alert(result); } </script>
.cs file
[WebMethod]
public static string MyMethod()
{return "Hello "; }