开发者

ASP.NET MVC Ajax OnBegin/Complete Javascript Problem

开发者 https://www.devze.com 2022-12-24 11:09 出处:网络
I am trying to fire off a javascript method using the OnBegin AjaxOption in an Ajax method. However, when debugging with firebug the callback in unable to find the Javascript method and I do not know

I am trying to fire off a javascript method using the OnBegin AjaxOption in an Ajax method.

However, when debugging with firebug the callback in unable to find the Javascript method and I do not know why.

My code is simple, first I use a basic Ajax method like this:

Then under it I decalre this script.

    <script type="text/javascript">

        function RunThisThing {
            alert("WORK")
        }
   开发者_如何学编程 </script>

Yet when I try running the page and clicking on the link, Firebug tells me "RunThisThing is not defined".

Any idea what I might be doing wrong?


You have a few bugs in your JavaScript code:

  1. You are missing the brackets () after your function name in it's definition.
  2. You are missing the semicolon on your alert statement.

This is how your JavaScript block should appear :

<script type="text/javascript">
  function RunThisThing() {
    alert("WORK");
  }
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消