167
rated 0 times
[
174]
[
7]
/ answers: 1 / hits: 91609
/ 11 Years ago, fri, october 25, 2013, 12:00:00
I am working on a Stock Exchange jQuery fix for a website.
EDIT: It updates a ID/CLASS or input value on the webpage depending on the value returned.
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>
Currently it is returning:
[object Object]
I have 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 can someone tell me what I did wrong.
Thanks in advance!
More From » jquery