Reputation: 11845
i need to change my code in jquery to dojo. The objective is only a snipset equivalent.
The jquery code works fine but the dojo code no.
JQUERY
<script type="text/javascript">
$(document).ready(function() {
$(".box").change(function() {
$.ajax({
dataType: 'json',
type: "POST",
data: "data=" + $(this).val(),
url: "file.php",
success: function(json) {
$msg = [];
for (var i = 1; i < 10; i++) {
$msg.push(parseFloat(json[i]["valor" + i]));
}
}
});
});
});
</script>
DOJO
<script type="text/javascript">
dojo.query(".box").onchange(function() {
dojo.xhrGet({
url: "file.php",
handleAs: "json",
data: "data=" + $(this).val(),
load: function(json) {
$msg = [];
for (var i = 1; i < 10; i++) {
$msg.push(parseFloat(json[i]["valor" + i]));
}
}
});
});
Upvotes: 1
Views: 1020
Reputation: 11845
Solved
<script type="text/javascript">
dojo.query(".box").onchange(function() {
dojo.xhrPost({
url:"drop2.php",
handleAs:"json",
postData: "data=" + $(this).val(),
preventCache: true,
load: function(json){
$msg = [];
for (var i = 1; i < 10; i++) {
$msg.push(parseFloat(json[i]["valor" + i]));
}
}
});
});
</script>
Upvotes: 1