I am working on a jQuery fix for Exchange on a website.
EDIT: it updates the ID / CLASS or input value on the web page depending on the return value.
index.php:
<!doctype html>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> <meta charset="utf-8"> <title>load demo</title> <script type="text/javascript"> $(document).ready(function() { $.ajax({ url: '/datacall/demo.json', dataType: 'json', success: function( resp ) { $( '#div' ).val( resp.currency[0].amount ); }, error: function( req, status, err ) { console.log( 'Something went wrong', status, err ); } }); var end = parseInt($('#value').val()); var newend = parseInt($('#div').val()); var result = $( end * newend ); $('#clickme').click(function() { $('#new').val( result ); }); }); </script>
<div> <input type="hidden" value="2500" id="value" /> <input type="hidden" value="" id="div"> <input type="text" id="new" value="" readonly/> <input type="button" value="Change" id="clickme" /> </div>
He is currently returning:
[object Object]
I also tried returning it to a div with .text ()
demo.json:
{ "currency" : [ { "name" : "South Africa", "code" : "ZAR", "amount" : 0.14 }, { "name" : "America", "code" : "USD", "amount" : 0.64 }, { "name" : "Europe", "code" : "GBP", "amount" : 1.29 } ] }
Please someone tell me what I did wrong.
Thanks in advance!
javascript jquery html ajax
Vaughan thomas
source share