简体   繁体   中英

Cannot get value from behind code to JavaScript

When I call the function from the javascript, I using this one:

PageMethods.pumpValue(signupname.value, signuppassword1.value, signupemail.value, signupnumber.value)

on my behind code I using this one:

<System.Web.Services.WebMethod()> _
Public Shared Function pumpValue(user As String, password As String, email As String, contact As String) As Boolean
end function

In the end I got the undefined even I return the true, can I get the value from the web method of the vb?

Make sure that you're referring to your UI controls properly. Currently, you're passing signupname.value . Try document.getElementById('signupname').value . The same goes for the other UI controls.

Also, make sure you're passing onSuccess and onFailure references when calling your PageMethods function. In the onSuccess function, you can pass the return value and use it. For example:

function onSuccess(resultFromVB){
    alert(resultFromVB); //this will show true or false from your server side function
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM