Last active
August 29, 2015 14:17
Revisions
-
iMagesh revised this gist
Mar 24, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ var pageUrl = "http://something.com/gsm"; var interactionId = "email-form"; //id of the product document.getElementsByClassName(interactionId).onsubmit = function AfterFunction(e){ var xmlhttp; if (window.XMLHttpRequest) { @@ -15,7 +15,7 @@ document.getElementByClass(interactionId).onsubmit = function AfterFunction(e){ xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 ) { if(xmlhttp.status == 200){ alert(JSON.stringify(customform(document.getElementsByClassName(interactionId)))); document.getElementById("myDiv").innerHTML = xmlhttp.responseText; } else if(xmlhttp.status == 400) { -
iMagesh revised this gist
Mar 24, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ document.getElementByClass(interactionId).onsubmit = function AfterFunction(e){ xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 ) { if(xmlhttp.status == 200){ alert(JSON.stringify(customform(document.getElementByClass(interactionId)))); document.getElementById("myDiv").innerHTML = xmlhttp.responseText; } else if(xmlhttp.status == 400) { -
iMagesh revised this gist
Mar 24, 2015 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,7 @@ var pageUrl = "http://something.com/gsm"; var interactionId = "email-form"; //id of the product document.getElementByClass(interactionId).onsubmit = function AfterFunction(e){ var xmlhttp; if (window.XMLHttpRequest) { -
iMagesh revised this gist
Mar 24, 2015 . 1 changed file with 28 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,34 @@ var pageUrl = "http://something.com/gsm"; var interactionId = "formSubmit"; //id of the product document.getElementById(interactionId).onsubmit = function AfterFunction(e){ var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 ) { if(xmlhttp.status == 200){ alert(JSON.stringify(customform(document.getElementById(interactionId)))); document.getElementById("myDiv").innerHTML = xmlhttp.responseText; } else if(xmlhttp.status == 400) { alert('There was an error 400') } else { alert('something else other than 200 was returned') } } } //alert(JSON.stringify(customform(document.getElementById(interactionId)))); } function customform(form) { @@ -70,4 +96,4 @@ function customform(form) { } } return q.join('&'); } -
iMagesh created this gist
Mar 24, 2015 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,73 @@ var pageUrl = "http://something.com/gsm"; var interactionId = "formSubmit"; //id of the product document.getElementById(interactionId).onsubmit = function AfterFunction(e){ alert(JSON.stringify(customform(document.getElementById(interactionId)))); } function customform(form) { var i, j, len, jLen, formElement, q = []; function addNameValue(name, value) { q.push(encodeURI(name) + '=' + encodeURI(value)); } if (!form || !form.nodeName || form.nodeName.toLowerCase() !== 'form') { throw 'You must supply a form element'; } for (i = 0, len = form.elements.length; i < len; i++) { formElement = form.elements[i]; if (formElement.name === '' || formElement.disabled) { continue; } switch (formElement.nodeName.toLowerCase()) { case 'input': switch (formElement.type) { case 'text': case 'hidden': case 'password': case 'button': // Not submitted when submitting form manually, though jQuery does serialize this and it can be an HTML4 successful control case 'submit': addNameValue(formElement.name, formElement.value); break; case 'checkbox': case 'radio': if (formElement.checked) { addNameValue(formElement.name, formElement.value); } break; case 'file': // addNameValue(formElement.name, formElement.value); // Will work and part of HTML4 "successful controls", but not used in jQuery break; case 'reset': break; } break; case 'textarea': addNameValue(formElement.name, formElement.value); break; case 'select': switch (formElement.type) { case 'select-one': addNameValue(formElement.name, formElement.value); break; case 'select-multiple': for (j = 0, jLen = formElement.options.length; j < jLen; j++) { if (formElement.options[j].selected) { addNameValue(formElement.name, formElement.options[j].value); } } break; } break; case 'button': // jQuery does not submit these, though it is an HTML4 successful control switch (formElement.type) { case 'reset': case 'submit': case 'button': addNameValue(formElement.name, formElement.value); break; } break; } } return q.join('&'); }