Basic Ajax send/receive with node.js

So I’m trying to make a very basic node.js server that with take in a request for a string, randomly select one from an array and return the selected string. Unfortunately I’m running into a few problems. Here’s the front end: function newGame() { guessCnt=0; guess=””; server(); displayHash(); displayGuessStr(); displayGuessCnt(); } function server() { xmlhttp … Read more

In ASP.NET MVC: All possible ways to call Controller Action Method from a Razor View

I know this is a pretty basic question over here. But could you tell me all possible options available to, call a Control Action Method [generally any server side routine] from a Razor View and, in what scenarios each are best applicable to be used in. Thanks. Answer Method 1 : Using jQuery Ajax Get … Read more

Javascript: How to read a hand held barcode scanner best?

I’d like to be able to scan barcodes via a hand held scanner and handle the results with Javascript. A barcode-scanner works almost like a keyboard. It outputs the scanned/translated (barcode->number) data raw (right?). Actually I just need to catch the output and proceed. But how? Here’s some pseudocode I’d like to make work: $(document).on(“scanButtonDown”, … Read more

Difference between $.ajax(); and $.ajaxSetup();

What is the difference between $.ajax(); and $.ajaxSetup(); in jQuery as in: $.ajax({ cache:false }); and $.ajaxSetup({ cache:true }); Also, which one is best option? Answer The following will prevent all future AJAX requests from being cached, regardless of which jQuery method you use ($.get, $.ajax, etc.) $(document).ready(function() { $.ajaxSetup({ cache: false }); }); you … Read more

ASP.NET UpdatePanel Time Out

I’m making a request from an UpdatePanel that takes more then 90 seconds. I’m getting this timeout error: Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerTimeoutException: The server request timed out. Does anyone know if there is a way to increase the amount of time before the call times out? Answer There is a property on the ScriptManager … Read more

Dynamically add item to jQuery Select2 control that uses AJAX

I have a jQuery Select2 control that uses AJAX to populate: <input type=”text” name=”select2″ id=”select2″ style=’width:400px’ value=”999″> var initialSelection = { id: ‘999’, text:”Some initial option”}; $(“#select2”).select2({ placeholder: “Select Option”, minimumInputLength: 2, ajax: { url: “/servletToGetMyData”, dataType: ‘json’, data: function (term, page) { return { term: term }; }, results: function (data, page) { return … Read more