Wednesday, 22 February 2017

Call Rest Api From Javascript With XMLHttpRequest

No comments
<form accept-charset="UTF-8" method="post" action="http://go" class="form" id="form"> </form>



function sendServiceProvider() {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://go.pardot.com/l/271212/2016-11-21/4y7');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function() {
if (xhr.status === 200) {
alert('Thank you for submitting the form. We will get back to you as soon as possible.');
}
else {
alert('Request failed.  Returned status of ' + xhr.status);
}
};
var val1 = document.getElementById('271212_1336pi_271212_1336').value;
var val2 = document.getElementById('271212_1338pi_271212_1338').value;
var val3 = document.getElementById('271212_1340pi_271212_1340').value;
var val4 = document.getElementById('271212_1342pi_271212_1342').value;
xhr.send(encodeURI('271212_1336pi_271212_1336=' + val1+'&271212_1338pi_271212_1338='+val2+'&271212_1340pi_271212_1340='+val3+'&271212_1342pi_271212_1342='+val4+'&271212_1344pi_271212_1344=Service Provider'));
}
read more

Thursday, 9 February 2017

Extend default Jquery function

No comments
For Example to resize canvas

(function($) {
$.fn.extend({
//Let the user resize the canvas to the size he/she wants
resizeCanvas:  function(w, h) {
var c = $(this)[0]
c.width = w;
c.height = h
}
})
})(jQuery)

$("#canvas").resizeCanvas(434, 434)



<canvas id="canvas">
</canvas>
read more