В настоящее время я пытаюсь вызвать метод в aspx.cs внутри моего JavaScript.
Вот то, что у меня сейчас есть:
Javascript:
function loadPins(passValue) {
callServer2("myMethod", passValue);
}
function callServer2(requestMethod, clientRequest) {
var pageMethod = "Default.aspx/" + requestMethod;
$.ajax({
type: 'POST',
data: clientRequest,
dataType: 'JSON',
contentType: 'application/json',
url: pageMethod , //Method to call
success: function (result, status) {
alert("success");
},
error: function (xhr, status, error) {
alert("ERROR");
}
});
}
Мой aspx.cs
:
[WebMethod]
public static string myMethod(string passedVal)
{
value = passedVal;
return "true";
}
Когда я отлаживаю, я вижу, как он звонит и вводит CallServer2
, но кажется, что он никогда не достигает моей точки останова в aspx. Я не вижу своих сообщений об ошибках или сообщениях об ошибках.
Есть предложения?
Ошибка, которую я сейчас получаю:
error - <html>
<head>
<title> Unknow we method myMethod.<br>Parameter name:
methodName</title>
<style>
body{font-family:verdana";font-weight:normal;font-size:
.7em;color:black}
p
{font-family:"Verdana";font-weightbold;color:black;margin-top: -5px}
b{font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1{
font-family:"veranda";font-weight:normal;font-size:18pt;colour:red}
H2{
font-family:"Verdana";font-weight:normal ;font-size:14pt color:maroon}
pre{font-family:"Lucida Console";font-size .9em}
.marker{font-weight:bold;color:black;text-decoration:none;}
.version{color:gray;}
.error{margin-bottom:10px}
.expandable{text-decoration:underline, font-weight:bold; color:navy; cursor:hand;}
</style>
<head>
<code>
An unhanded exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code>
...
* Примечание Я не поставил ... вот и все, что сказано после строки выше