PM's Blog

Pramod Mohanan's notes about ASP.NET, MVC, C#, SQL, jQuery, Bootstrap

jQuery/Javascript

Simple Accordian using Jquery

The following jquery script can be used to create an accordian effect. Add the class 'handler' to the clickable element and 'expandable' to the element that needs to be toggled. <script type="text/javascript">   $(document).ready(function () {     $(".expandable").hide();     $(".handler").click(function () {       if ($(this).siblings(".expandable").css("display") == "none")       { […]

Cross Domain Ajax using jQuery

Browsers by default don't allow cross domain ajax. Conceptually we can implement JSONP (see http://en.wikipedia.org/wiki/JSONP) using jquery to do this. Here is an example <script type="text/javascript"> $(document).ready(function () {    var s = $.ajax({ url: "http://someotherdomain.com/page?callback=?", context: document.body, dataType: "jsonp" }); }); function populate(data) {   $(".info").html(unescape(data)); } </script> <button id="btn" value="click me" /> <div […]
PM's Blog © 2018