i have these simple files in head section of html this----
<!doctype html> <head> <title></title> <script src="~/scripts/jquery-2.1.4.js"></script> <script src="~/scripts/jquery.unobtrusive-ajax.js"></script> <script src="~/scripts/city.js"></script> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js? sensor=false"></script> </head> in body section have simple method open alert box on click function:
<body> @using (html.beginform()) { @html.antiforgerytoken() @html.validationsummary(true) <fieldset> <legend>enter project details</legend> <div class="editor-label"> @html.labelfor(model => model.city) </div> <div class="editor-field"> @if (viewdata.containskey("city")) { @html.dropdownlistfor(model => model.city, viewdata["city"] list<selectlistitem>, new { style = "width:250px", @class = "dropdown1"}) @html.validationmessagefor(model => model.city) } </div> <script type="text/javascript"> $(document).ready(function() { var map; $("#city").click(function() { $.get("city.js", function () { var jsonobject = json.parse(data); alert("data : " + data); }); }); }); </script> i have city.js file in scripts folder in ui tier of asp.net mvc application. want know why js code not running.
you missing 1 closing tag }); .. place @ end
<script type="text/javascript"> $(document).ready(function() { var map; $("#city").click(function() { $.get("city.js", function () { var jsonobject = json.parse(data); alert("data : " + data); }); // closing $.get("city.js" });// closing $("#city").click }); // closing (document).ready </script>
Comments
Post a Comment