Ajax call via JSON returning variables that aren't there and I can't delete or change

I have a script making an AJAX call:

$.ajax({
    url: pageURL,
    data: loadData,
    type: 'POST',
    cache: false,
    dataType: 'json',
    success: function (data) { //if the call was successful
        console.log(successFunc);
        dataNew = data;
        delete dataNew.total;
        console.log(dataNew);
        console.log(dataNew.total);
        successFunc(dataNew);
    },
    error: function (xhr, status, errorThrown) { //throw errors if we fail
        $('#loading').css('display', 'none'); //hide loading popup
        $("#login").modal('hide');

        if (typeof errorFunc !== "undefined") errorFunc();  //if there is a function associated with failing call it

        scripts.throwNetworkError(xhr, status, errorThrown, errorType);
    },
    timeout: 15000    // wait 15 seconds before failing
});

It calls to a PHP page that returns a JSON encoded object:

$returnData = json_encode($retData);

echo $returnData;

The problem is, I was having trouble with a particular variable, $retData->total, that was treating numbers like strings and adding them together like "543" instead of 12. But no matter what I did, I couldn't fix it.

So I removed every mention to the variable "total" in the PHP script. Changed the name to "totalNum". So in the JSON object, totalNum would come through, but ALSO "total", even though that variable doesn't exist!

Below is the result of the console.log(dataNew) that was returned:

Object
cart: [Object, Object] (2)
mark0: "XXA"
message: "delete"
name: null
out_of_stock: null
part_num: "854210"
quantity: null
total: "0196.443.08"
totalNum: 199.52
vendor: null

You can see "total" is still there.

Also, before I called:

console.log(dataNew);

I tried:

delete dataNew.total;

But it's still there.

I can't get rid of this variable from either end.

How do I get rid of it? Keeping in mind, ideally, I want the nice numeric variable "totalNum" to be "total", but "total" in its current form won't be altered, edited, or deleted no matter what I try.

Answers


Looks like there are some Global Ajax Event Handlers like ajaxSuccess modifying your request.responseText.


Need Your Help

Windows Mobile 6 CPU architectures?

windows-mobile cpu-architecture

Does windows Mobile 6 run on multiple processor architectures? Or is it just ARM generation X? I'm asking because I want to know whether I can compile a native binary program for it and be sure tha...