Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
I have currency convertor
C#
function getCurrencyUsingJQuery() {
            var fr = "USD";
            var currToSelect = $("#CURR_FR");
            var to = currToSelect.val();
            $('.changeCurrency').text("SELECT CURRENCY : " + to);

            var currId = fr + "-" + to;
            $.getJSON("http://www.freecurrencyconverterapi.com/api/convert?q=" + currId + "&compact=y&callback=?",
            function (data) {
                try {
                    $('div.price').text(function (i, oldtext) {
                        var currFrVal = parseFloat(oldtext);
                        $(this).text(numeral(currFrVal * data[currId].val).format("0,0.00[0]"));
                    })
                } catch (e) {
                    alert("Currently This Currency is not available.");
                }
            });
        }




In this code i m setting the text of div, so there is some problem
if rather than (setting text of div), if i will assign the text to a input textbox its working...
please solve my issue
Thanx
Posted
Comments
Snesh Prajapati 25-Apr-14 5:21am    
As you are saying that it is working sine with input textbox. instead of div you can try with span.
Kishor Khatri 25-Apr-14 5:49am    
No, its not working with span also

1 solution

Please do the following change and check that.Use return with the call back function.

C#
$('div.price').text(function (i, oldtext) {

   var currFrVal = parseFloat(oldtext);
   return numeral(currFrVal * data[currId].val).format("0,0.00[0]");
})
 
Share this answer
 
Comments
Kishor Khatri 25-Apr-14 7:31am    
Thanx For Your Answer...
But i sloved it...
Thank you so much for your response
Sampath Lokuge 25-Apr-14 7:33am    
Is this the answer or else ?
Kishor Khatri 25-Apr-14 7:47am    
sry, but still i didn't try this
Sampath Lokuge 25-Apr-14 7:51am    
OK.Then plz put your solution and mark it as a solution.It'll help for others in future.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900