How do you make an element “flash” in jQuery

My way is .fadein, .fadeout .fadein, .fadeout …… $(“#someElement”).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100); function go1() { $(“#demo1″).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100)} function go2() { $(‘#demo2’).delay(100).fadeOut().fadeIn(‘slow’) } #demo1, #demo2 { text-align: center; font-family: Helvetica; background: IndianRed; height: 50px; line-height: 50px; width: 150px; } <script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js”></script> <button onclick=”go1()”>Click Me</button> <div id=’demo1′>My Element</div> <br> <button onclick=”go2()”>Click Me</button> (from comment) <div id=’demo2′>My Element</div>

How do I make jQuery wait for an Ajax call to finish before it returns?

If you don’t want the $.ajax() function to return immediately, set the async option to false: $(“.my_link”).click( function(){ $.ajax({ url: $(this).attr(‘href’), type: ‘GET’, async: false, cache: false, timeout: 30000, fail: function(){ return true; }, done: function(msg){ if (parseFloat(msg)){ return false; } else { return true; } } }); }); But, I would note that this … Read more

What’s the point of the X-Requested-With header?

A good reason is for security – this can prevent CSRF attacks because this header cannot be added to the AJAX request cross domain without the consent of the server via CORS. Only the following headers are allowed across origins: Accept Accept-Language Content-Language Last-Event-ID Content-Type any others cause a “pre-flight” request to be issued in … Read more

Pass request headers in a jQuery AJAX GET call

As of jQuery 1.5, there is a headers hash you can pass in as follows: $.ajax({ url: “/test”, headers: {“X-Test-Header”: “test-value”} }); From http://api.jquery.com/jQuery.ajax: headers (added 1.5): A map of additional header key/value pairs to send along with the request. This setting is set before the beforeSend function is called; therefore, any values in the … Read more

Is there a way to disable initial sorting for jquery DataTables?

Well I found the answer set “aaSorting” to an empty array: $(document).ready( function() { $(‘#example’).dataTable({ /* Disable initial sort */ “aaSorting”: [] }); }) For newer versions of Datatables (>= 1.10) use order option: $(document).ready( function() { $(‘#example’).dataTable({ /* No ordering applied by DataTables during initialisation */ “order”: [] }); })

twitter bootstrap typeahead ajax example

Edit: typeahead is no longer bundled in Bootstrap 3. Check out: Where is the typeahead JavaScript module in Bootstrap 3 RC 1? typeahead.js As of Bootstrap 2.1.0 up to 2.3.2, you can do this: $(‘.typeahead’).typeahead({ source: function (query, process) { return $.get(‘/typeahead’, { query: query }, function (data) { return process(data.options); }); } }); To … Read more

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