Why am I getting an OPTIONS request instead of a GET request?

According to MDN, Preflighted requests Unlike simple requests (discussed above), “preflighted” requests first send an HTTP OPTIONS request header to the resource on the other domain, in order to determine whether the actual request is safe to send. Cross-site requests are preflighted like this since they may have implications to user data. In particular, a … Read more

How to set data attributes in HTML elements

HTML <div id=”mydiv” data-myval=”10″></div> JS var a = $(‘#mydiv’).data(‘myval’); //getter $(‘#mydiv’).data(‘myval’,20); //setter Demo Reference From the reference: jQuery itself uses the .data() method to save information under the names ‘events’ and ‘handle’, and also reserves any data name starting with an underscore (‘_’) for internal use. It should be noted that jQuery’s data() doesn’t change … Read more

how to set radio option checked onload with jQuery

Say you had radio buttons like these, for example: <input type=”radio” name=”gender” value=”Male”> <input type=”radio” name=”gender” value=”Female”> And you wanted to check the one with a value of “Male” onload if no radio is checked: $(function() { var $radios = $(‘input:radio[name=gender]’); if($radios.is(‘:checked’) === false) { $radios.filter(‘[value=Male]’).prop(‘checked’, true); } });

jQuery UI: Datepicker set year range dropdown to 100 years

You can set the year range using this option per documentation here http://api.jqueryui.com/datepicker/#option-yearRange yearRange: ‘1950:2013′, // specifying a hard coded year range or this way yearRange: “-100:+0″, // last hundred years From the Docs Default: “c-10:c+10” The range of years displayed in the year drop-down: either relative to today’s year (“-nn:+nn”), relative to the currently … Read more

Detect changed input text box

You can use the input Javascript event in jQuery like this: $(‘#inputDatabaseName’).on(‘input’,function(e){ alert(‘Changed!’) }); In pure JavaScript: document.querySelector(“input”).addEventListener(“change”,function () { alert(“Input Changed”); }) Or like this: <input id=”inputDatabaseName” onchange=”youFunction();” onkeyup=”this.onchange();” onpaste=”this.onchange();” oninput=”this.onchange();”/>

Adding attribute in jQuery

You can add attributes using attr like so: $(‘#someid’).attr(‘name’, ‘value’); However, for DOM properties like checked, disabled and readonly, the proper way to do this (as of JQuery 1.6) is to use prop. $(‘#someid’).prop(‘disabled’, true);

Auto-size dynamic text to fill fixed size container

Thanks Attack. I wanted to use jQuery. You pointed me in the right direction, and this is what I ended up with: Here is a link to the plugin: https://plugins.jquery.com/textfill/ And a link to the source: http://jquery-textfill.github.io/ ;(function($) { $.fn.textfill = function(options) { var fontSize = options.maxFontPixels; var ourText = $(‘span:visible:first’, this); var maxHeight = … Read more

Bootstrap 3 jquery event for active tab change

$(‘a[data-toggle=”tab”]’).on(‘shown.bs.tab’, function (e) { var target = $(e.target).attr(“href”) // activated tab alert(target); }); <script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js”></script> <script src=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script> <link href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css” rel=”stylesheet”/> <ul id=”myTab” class=”nav nav-tabs”> <li class=”active”><a href=”#home” data-toggle=”tab”>Home</a></li> <li class=””><a href=”#profile” data-toggle=”tab”>Profile</a></li> </ul> <div id=”myTabContent” class=”tab-content”> <div class=”tab-pane fade active in” id=”home”> home tab! </div> <div class=”tab-pane fade” id=”profile”> profile tab! </div> </div>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)