0

我正在 JQuery Mobile 的帮助下制作一个 android 应用程序。在这些应用程序中,我想转换用户想要的货币,它应该在全球范围内检查它是那个时间和那天的货币汇率

在 HTML5 中:-

 <label for="amount">Convert this amount:</label>
    <input type="text" name="amount" id="amount" value="" />
 <div class="data">
    <label for="fromCurrency">From this currency:</label>
    <select name="fromCurrency" id="fromCurrency">
      <option selected="" value="EUR">Euro - EUR</option>
      <option value="USD">United States Dollars - USD</option>
      <option value="GBP">United Kingdom Pounds - GBP</option>
      <option value="CAD">Canada Dollars - CAD</option>
      <option value="AUD">Australia Dollars - AUD</option>
      <option value="JPY">India Rupees - JPY</option>
    </select>
</div>
<div class="data">
    <label for="toCurrency">To this currency:</label>
    <select name="toCurrency" id="toCurrency">
      <option value="USD">United States Dollars - USD</option>
      <option value="GBP">United Kingdom Pounds - GBP</option>
      <option value="CAD">Canada Dollars - CAD</option>
      <option value="AUD">Australia Dollars - AUD</option>
      <option value="JPY">Japan Yen - JPY</option>
      <option value="INR">India Rupees - INR</option>
    </select>
</div>

    <input type="button" name="convert" id="convert" value="Convert" />

    <div id="results"></div>

在 JQuery 中:-

  $(document).ready(function() {
     $('#convert').click(function(){
         var amount = $('#amount').val();
         var from = $('#fromCurrency').val();
         var to = $('#toCurrency').val();
         var dataString = "amount=" + amount + "&from=" + from + "&to=" + to;
            $.ajax({
               type: "POST",
               url: "http://www.google.com/ig/calculator?hl=en&q="+dataString,
               data: dataString,
               success: function(data){
                $('#results').show();
                $('#results').html(data);
               }
            });
         });
     });

我在这里做错了什么它不会来

请帮帮我

在头标签内,我使用了以下脚本

  <meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
4

1 回答 1

1

这是工作代码:

 $('#convert').click(function(){
         var amount = $('#amount').val();
         var from = $('#fromCurrency').val();

         var to = $('#toCurrency').val();
         var dataString = from + "&to=" + to + "&q=" + amount;

         $.ajax({
            type: "POST",
            crossDomain: true,
            dataType: 'jsonp',
            contentType: "application/json; charset=utf-8",   
            url: "http://rate-exchange.appspot.com/currency?from=" + dataString,
            success: function(data){
              alert(JSON.stringify(data));
              $('#results').show();
              $('#results').html(data.v);
            },error: function(xhr, status, error) {
              alert(xhr.responseText);
            }
        });
    }); 
于 2013-10-04T09:31:58.143 回答