I'm using jquery $.when to call a REST url which returns json.
When I execute $.when with a single parameter I get different object in data1 result than when I execute multiple ones, even though return parameters should all be independent.
<script>
$(document).ready(function () {
fun1(1025);
fun2(1025);
function fun1(id) {
$.when(_restFun1(id), _restFun1(id)).done(function(data1, data2) {
console.log(data1);
});
}
function fun2(id) {
$.when(_restFun1(id)).done(function(data1) {
console.log(data1);
});
}
});
</script>
the objects printed to console.log are different even though the two functions should print the same object!.
NOTE:
the _restFun1 function is something like this:
function _restFun1(id)
{
return $.ajax({
url: "http://192.123.12.3/test.php?id="+id,
data: "",
dataType: 'json',
success: function (data1) {
}
});
}
which returns a json object, in one case I get the json object as it is, in the case of multiple calls I get an object with multiple other fields like responseText, responseJSON, a "success" string and then in an array the real JSON thing I needed.