Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » ASP.NET » Howto » Downloads
 
Add your own
alternative version
Go to top

ASP.NET Real-time Currency Converter using API (Google, Yahoo), Web service, and jQuery Ajax

, 15 Jul 2012
Here I’m going to show a ASP.NET Real-time Currency Converter using Google’s/Yahoo’s API , jQuery Ajax, Webservice, $.ajax beforeSend Success Error, Webservice ScriptService Attribute, WebClient DownloadString
CurrencyConverter_VS2008_GOOGLE-noexe.zip
CurrencyConverter_VS2008_GOOGLE
CurrencyConverter_VS2008_GOOGLE
bin
CurrencyConverter_VS2008_GOOGLE.pdb
CSS
CurrencyConverter_VS2008_GOOGLE.csproj.user
JQuery
obj
Debug
CurrencyConverter_VS2008_GOOGLE.pdb
TempPE
Properties
CurrencyConverter_VS2008_GOOGLE.suo
CurrencyConverter_VS2008_GOOGLE.zip
CurrencyConverter_VS2008_GOOGLE.dll
CurrencyConverter_VS2008_GOOGLE.pdb
CurrencyConverter_VS2008_GOOGLE.csproj.user
CurrencyConverter_VS2008_GOOGLE.dll
CurrencyConverter_VS2008_GOOGLE.pdb
CurrencyConverter_VS2008_GOOGLE.suo
CurrencyConverter_VS2008_YAHOO-noexe.zip
CurrencyConverter_VS2008_YAHOO
CurrencyConverter_VS2008_YAHOO
bin
CurrencyConverter_VS2008_YAHOO.pdb
CSS
CurrencyConverter_VS2008_YAHOO.csproj.user
JQuery
obj
Debug
CurrencyConverter_VS2008_YAHOO.pdb
TempPE
Properties
CurrencyConverter_VS2008_YAHOO.suo
CurrencyConverter_VS2008_YAHOO.zip
CurrencyConverter_VS2008_YAHOO.dll
CurrencyConverter_VS2008_YAHOO.pdb
CurrencyConverter_VS2008_YAHOO.csproj.user
CurrencyConverter_VS2008_YAHOO.dll
CurrencyConverter_VS2008_YAHOO.pdb
CurrencyConverter_VS2008_YAHOO.suo
CurrencyConverter_VS2010_GOOGLE-noexe.zip
CurrencyConverter_VS2010_GOOGLE
CurrencyConverter_VS2010_GOOGLE
bin
CurrencyConverter_VS2010_GOOGLE.pdb
CSS
CurrencyConverter_VS2010_GOOGLE.csproj.user
JQuery
obj
Debug
CurrencyConverter_VS2010_GOOGLE.pdb
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Properties
CurrencyConverter_VS2010_GOOGLE.suo
CurrencyConverter_VS2010_GOOGLE.zip
CurrencyConverter_VS2010_GOOGLE.dll
CurrencyConverter_VS2010_GOOGLE.pdb
CurrencyConverter_VS2010_GOOGLE.csproj.user
CurrencyConverter_VS2010_GOOGLE.dll
CurrencyConverter_VS2010_GOOGLE.pdb
DesignTimeResolveAssemblyReferencesInput.cache
CurrencyConverter_VS2010_GOOGLE.suo
CurrencyConverter_VS2010_YAHOO-noexe.zip
CurrencyConverter_VS2010_YAHOO
CurrencyConverter_VS2010_YAHOO
bin
CurrencyConverter_VS2010_YAHOO.pdb
CSS
CurrencyConverter_VS2010_YAHOO.csproj.user
JQuery
obj
Debug
CurrencyConverter_VS2010_YAHOO.pdb
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Properties
CurrencyConverter_VS2010_YAHOO.suo
CurrencyConverter_VS2010_YAHOO.zip
CurrencyConverter_VS2010_YAHOO.dll
CurrencyConverter_VS2010_YAHOO.pdb
CurrencyConverter_VS2010_YAHOO.csproj.user
CurrencyConverter_VS2010_YAHOO.dll
CurrencyConverter_VS2010_YAHOO.pdb
DesignTimeResolveAssemblyReferencesInput.cache
CurrencyConverter_VS2010_YAHOO.suo
/*
* Created By Shemeer NS 
* This Code is created for demo purpose and uploaded in Codeproject
* My Other Articles in codeproject - http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=3175840
* */
$(document).ready(function () {
    $('#submit').click(function () {
        var errormsg = "";
        var amount = $('#txtAmount').val();
        var from = $('#drpFrom').val();
        var to = $('#drpTo').val();
        $.ajax({ type: "POST",
            url: "WebService.asmx/ConvertYHOO",
            data: "{amount:" + amount + ",fromCurrency:'" + from + "',toCurrency:'" + to + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            beforeSend: function () {
                $('#results').html("Converting...");
            },
            success: function (data) {
                $('#results').html(amount + ' ' + from + '=' + data.d.toFixed(2) + ' ' + to);
            },
            error: function (jqXHR, exception) {
                if (jqXHR.status === 0) {
                    errormsg = 'Not connect.\n Verify Network.'; ;
                } else if (jqXHR.status == 404) {
                    errormsg = 'Requested page not found. [404]'; ;
                } else if (jqXHR.status == 500) {
                    errormsg = 'Internal Server Error [500].'; ;
                } else if (exception === 'parsererror') {
                    errormsg = 'Requested JSON parse failed.'; ;
                } else if (exception === 'timeout') {
                    errormsg = 'Time out error.'; ;
                } else if (exception === 'abort') {
                    errormsg = 'Ajax request aborted.'; ;
                } else {
                    errormsg = 'Uncaught Error.';
                }
                $('#results').html(errormsg);
                $('<a href="#" >Click here for more details</a>').click(function () {
                    alert(jqXHR.responseText);
                }).appendTo('#results');
            }
        });
    });
});

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)

Share

About the Author

Shemeer NS
Software Developer (Senior)
India India
Technology Specialist | CodeProject MVP | Visual Studio Gallery Contributor | Author | Geek | Netizen | Husband | ChessPlayer
 
Most of my articles are listed on top 5 of the respective 'Best articles of the month' and some of my articles are published on ASP.NET WebSite's Article of the Day section.
 
Check my contributions in Visual Studio Gallery and Code Project
 
Technical Blog: http://www.shemeerns.com
Facebook: http://facebook.com/shemeernsblog
Twitter : http://twitter.com/shemeerns
Google+ : http://google.com/+Shemeernsblog
Follow on   Twitter   Google+

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 15 Jul 2012
Article Copyright 2012 by Shemeer NS
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid