REST / jQuery

  Cross-Domain Dynamic Client

Table of Contents
REST / jQueryPrint||
Cross-Domain Dynamic Client

A fictitious company Northwind Traders had a fair amount of success with the statically exposed product catalog that allows third parties to display the catalog on their own web sites. An exceptionally small amount of code is required to create a jQuery cross-domain static client of the back office web app created with Code On Time.

Northwind Traders have decided to offer search capabilities of the back office web app to their premium integration partners.

A possible implementation of a search client is shown next.

If a user clicks Find without entering a search sample,  then the first one hundred products are retrieved in alphabetical order.

The search result displayed in jQuery cross-domain dynamic client of the demo web app when a search criteria is not specified

This is the result that matches “40 biscuit” search criteria.

The search result displayed in jQuery cross-domain dynamic client of the demo web app with '40 biscuit' search sample

The back office web app at displays the same exact result as follows.

The 'Quick Find' result for '40 biscuit' search sample in the demo web app created with Code On Time

The HTML page implementing a sample search client works across domains in any web browser.

<!DOCTYPE html>
<html xmlns="">
    <title>jQuery Cross-Domain Client</title>
    <script src=""></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#FindButton').click(function (e) {
                var query = '?_sortExpression=ProductName&_q=' +
                    url: '' + query,
                    cache: false,
                    dataType: 'jsonp',
                    success: function (data) {
                        $('#ProductList option').remove();
                        $.each(data.Products, function (index, product) {
                                    product.ProductName + ' / ' +
                                    product.CategoryCategoryName + ' / ' +
                                    product.SupplierCompanyName + ' / ' +
                                .attr('value', product.ProductID)
    <input id="Query" type="text" />
    <button id="FindButton">
    <div id="ProductListPanel">
        <select id="ProductList" size="10">

The page statically links jQuery library from CDN provided by Google.

The search starts when a user clicks on the Find button.

The “click” handler declares a query variable that contains “_sortExpression” and “_q” parameters. The first parameter specifies the sort order of returned products. The search parameter “_q” is the sample for the Quick Find feature of the web app.

Next, the “click” handler invokes ajax method to retrieve data from the web app. The key parameters of the method are url and dataType. The first parameter defines the REST URI of Products data controller. The second parameter indicates that a cross-domain web request must be executed by jQuery library.

If the request is successful, then a list of products populates the list box.