Shaun Mccran

My digital playground
 
19
J
U
L
2010

Cross site AJAX HttpRequest problems and how to create a Proxy handler

Most of us are familiar with the AJAX post() and getJSON() methods of remotely calling and passing around data, I use them with abundance when building applications. One thing I had not considered until recently is that all my AJAX Http requests are usually internal to that application, which also means they are on the same server and domain.

I recently jumped into a project where the application spanned 24 domains, and had been developed to use a core component library to help code re use. The problem with this arose when you are on one domain (www.domain1.com) and you want to make a request to a different domain (www.domain2.com). You encounter something called the 'same-Origin' policy.

This article deals with how to create a proxy to handle cross site AJAX http Requests.

[More]

 
05
J
U
L
2010

Using the JQuery Cookie plugin to emulate server side forms

A project request recently came up where we needed to track some users responses to a series of questions, then build an account 'home' page based on those responses. Pretty straight forward you'll agree. The problem here arose from the clients using a bespoke online solution that blocked any kind of server side interaction.

I've played with JavaScript cookies in the past to remember display states in JQuery functions, so I thought they would be a great solution to this. This article deals with how to use JavaScript cookies to emulate a normal form submission.

There is a demo of using the JQuery Cookie plugin to emulate forms here.

[More]

 
02
J
U
L
2010

How to reload a JQuery Datatables table data, using the API

Since I found the JQuery dataTables plugin, I use it quite a lot. I think it's a great way to display tabulated data, and it provides simple easy to use pagination and filtering options.

I've been building an interface to manage data, and arrived at the need to reload a datatable powered table, through a JavaScript request, rather than a page reload, or external variable (Url or form).

The problem with this is that if you try and re initialise a datatable into an existing datatable you get an error:

view plain print about
1DataTables warning: Unable to re-initialise DataTable. Please use the API to make any configuration changes required.

So you cannot re initialise an existing dataTable object. Looking through the API methods there is a relatively straight forward fix.

view plain print about
1if (typeof dTable == 'undefined') {
2
3    dTable = $('#example').dataTable( {
4    // data tables code
5    "bProcessing": true,
6    "bStateSave": true,
7    "bServerSide": true,
8etc...
9    aoData.push({ "name": "pageFilter", "value": filterText });
10    });
11else
12        {
13            dTable.fnDraw();
14        }

This code is basically checking if the object 'dTable' already exists, and if it is we are re drawing it, rather than using the existing object.

The fnDraw() method re-draws the table, so the data is refreshed. It uses the fnClearTable() method to first clear an existing data set, and the re draws it.

As an aside the 'filterText' value is a JavaScript value set elsewhere (a select field) that I am sending through to my server side request. It is used in a simple where clause in a query.

 
15
J
U
N
2010

JQuery 101: Setting html attributes and content using JQuery

This article follows one from a few days ago, where I explained how to use the JQuery .attr() method to get html attributes. In this article I will show you how a small change to the same .attr() method will allow you to set the value of html attributes.

I'll also cover the .text() and .html methods as they allow very similar functionality.

This article is the second in a planned series demonstrating some of the key concepts of the JQuery library, and how to use it, starting at a beginner level and working up.

Here is an example of setting attributes using JQuery.

[More]

 
11
J
U
N
2010

JQuery 101: Getting html attributes using JQuery

One of the things I find myself doing a lot in JQuery is getting and setting html attributes. It is very easy indeed to get the values of attributes, much like the old style document.getElementById javascript method, except in JQuery it is much easier.

This article is the first in a planned series demonstrating some of the key concepts of the JQuery library, and how to use it, starting at a beginner level and working up.

Here is an example of getting attributes using JQuery.

[More]

 
10
M
A
Y
2010

Incredibly simple JQuery image change on mouse over effect

I was recently asked in conversation if it would be possible to have a list of items, and when a user mouse'd over the headers in the list, an image effect happened, IE a thumbnail image was displayed. I figured this would be an ideal use for JQuery, so this article is how to write an incredibly simple JQuery image change.

There is a full demo of this here: JQuery mouse over demo

[More]

 
04
M
A
Y
2010

JQuery multiple show and hide div’s based on click event

This article shows how to use JQuery to show and hide many div's at the same time, revealing the content that the user requests. It also degrades gracefully if you turn off Javascript.

Have you ever tried to display a Questions and Answers type page, where the Question is a clickable link that shows the corresponding Answer (FAQ's)? It is quite tricky to make this interesting, and Accessible to impaired users.

A full demo of multiple show and hide divs is here: link

[More]

 
29
A
P
R
2010

JQuery Datatables plugin example using a server side data request (coldfusion)

Im my previous article on how to use the JQuery datatables plug I concentrated mainly on the JQuery script, and how to build the AJAX request to receive a JSON response.

In this article I will demonstrate the full application which will include the front end JQuery, building the back end server response and a few tips that I've picked up since implementing the plugin. I am using an MS SQL table filled with UK location data that I also used for a weather webservice, to fill the table.

A full example of this working can be seen here: Data table server side example

[More]

More Entries


This content is purely my opinon, any offence or errors are unintentional, please comment your views appropriately
Site Credits
Aggregated by ColdfusionBloggers.org Powered by Coldfusion

Technology & Science Blogs - BlogCatalog Blog Directory Blog Directory & Search engine