Click here to Skip to main content
15,881,248 members
Articles / Web Development / HTML

A simple POC using ASP.NET Web API, Entity Framework, Autofac, Cross Domain Support

Rate me:
Please Sign up or sign in to vote.
4.92/5 (43 votes)
27 Oct 2012CPOL11 min read 338.4K   8.3K   154  
The purpose of this article is to create a proof of concept to demonstrate the feasibility of ASP.NET Web API Beta Version.
 jQuery.support.cors = true;
 var salesAddress = "http://localhost:8080/api/sales";

 $(function () {
     var SalesHeader = salesAddress + "/" + getUrlVars()["SalesHeader"];
     $.getJSON(
        SalesHeader,
        function (value) {
            $("#SalesDetails").html("");
            value.OrderDate = value.OrderDate.substring(0, 10);
            $("#SalesTemplate").tmpl(value).appendTo("#SalesDetails");
            $("#ProductTemplate").tmpl(value.products).appendTo("#ProductsDetails");
        }
    );

        $("#btnShopAgain").live("click", function () {
            window.location.replace("Products.htm");
        });
 });


function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions