Tag Archives: javascript

How to get variables from a URL using Javascript

How to get variables from a URL using javascript. // ex url: http://www.example.com/index.html?hello=bonjour&goodevening=bonsoir var hash = getUrlVars(); alert(hash['hello']); // prints ‘bonjour’ function getUrlVars() { var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf(‘?’) + 1).split(‘&’); for(var i = 0; i … Continue reading

Posted in Javascript | Tagged , , | 2 Comments

AJAX function using jquery

Jquery ajax function var ajax = { go: function(type, url, data, callback) { $.ajax({ type: type, url: url, data: data, success: function(msg){ callback(msg); }, error: function(XMLHttpRequest, textStatus, errorThrown){ alert(errorThrown); } }); } };

Posted in Javascript, Jquery | Tagged , , , , | Leave a comment