Skip to main content

Posts

Showing posts from February, 2015

Capturing Enter-key click event via Javascript (JQuery)

The Problem: The website I work on has a search submit button inherited on all pages.  Some pages have forms with submit buttons.  the result:  Enter-key click event chaos! Currently, when a user fills a form and clicks the enter key to submit it, the search box submit button is triggered rather than the form button. Therefore, user gets pissed. The Solution: I captured the enter key click event on page load and set what button to be triggered when enter-key is pressed.  If a form buttons is visible, click that submit button first.  If not, let the enter key trigger the search box submit button as usual. The Code: $(document).bind('keypress',function(e){ if(e.keyCode === 13) { var buttons = $('.continue-button:visible'); if(buttons.filter('#formSubmit').length > 0) buttons.filter('#formSubmit').click(); else if (buttons.filter('.next').length > 0) buttons.filter('.next').click(...

Large Data and JSONP - Dealing with IE's Cross Domain Headaches

The Problem: I created dynamic form generating application which sends form data (json object via JQuery ajax call) to an endpoint which then stores data to a database.  I’m using a third party service which appends more data to the object (company data by email address/IP address) which makes the object HUGE!  Posting the data to the endpoint works perfectly (Chrome and Firefox ), but IE, not so much.   Here’s the issues: The form generator app is used on cross-domain sites, which IE isn’t too happy about.   In other words, No Posting! JSONP works with GET requests, but the 2083 char limit in IE chops the request, resulting in No Transport or json call fail. Json = Error: jQuery was not called The Idea: What if I did the following: Create a new endpoint called “ThanksIE” Chop the json object every 1500 characters and sent multiple jsonp requests to  new endpoint. Each request will also have a similar guid, and index parameter ...