jquery - JavaScript not being called at all. It is being loaded in the developer tools, though -
jquery - JavaScript not being called at all. It is being loaded in the developer tools, though -
i have master page declares <script> tags in order:
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width" /> <title>@viewbag.title</title> @styles.render("~/content/css") @scripts.render("~/bundles/modernizr") @scripts.render("~/bundles/jquery") </head> <body style= "margin-left: 40px; margin-top: 30px;"> @{ html.renderpartial("_login"); } @renderbody() @rendersection("scripts", required: false) </body> </html> i have partial view, load in 1 of views:
@using(var form = @html.beginform("requestnewverificationcode", "account", formmethod.post, new { name = "frmrequestnewverificationcode" })) { <fieldset> <p> email @html.textbox("email", null, new { id = "txtemail" }) <input type="button" value="request new verification code" id="btnrequestnewverificationcode" /> </p> </fieldset> <p> <div id= "divmessage"></div> </p> } @scripts.render(@url.content("~/scripts/requestnewverificationcode.js")) the contents of requestnewverificationcode.js follows:
$(document).ready(requestnewverificationcode.wirehandlers); var requestnewverificationcode = { wirehandlers : function() { debugger; $("#btnrequestnewverificationcode").bind("click", this.makeajaxrequest); }, url: '/account/requestnewverificationcode', makeajaxrequest: $.ajax(url, { cache: false, async: false, type: 'post', data: json.stringify( { 'email': $("#txtemail").val() }), datatype: 'json', contenttype: 'application/json', success: onsuccess, error: onerror }), onsuccess: function(data, textstatus, jqxhr) { }, onerror: function (jqxhr, textstatus, errorthrown) { } }; however, break-points set in js file not beingness nail @ all. not able debug it.
ah, got it. 1 bites me.
i recall in javascript, if declare object syntax using, i.e. if say:
var foo = { }; // syntax rather one:
var foo = new object(); then, cannot utilize foo before declaring it, i.e. javascript not hoist symbol. so:
foo.bar() // illegal because foo not yet declared var foo = { }; // syntax whereas:
foo.bar(); // legal var foo = new object(); // syntax javascript jquery asp.net-mvc
Comments
Post a Comment