Select to view content in your preferred language

init.js:89 Error: JSON does not allow non-finite numbers.(…)

1960
4
08-03-2016 03:09 PM
RichardMoussopo
Occasional Contributor III

Just came accross this error and I am quite confused. All I am doing is using the FindTask to find features. This works fine with some values but don't with some other values even though those values exist. instead, it throws me the above error. here is the code:

   var initAssetSearch = function () {
        query(".txt-asset-finder").connect("onkeydown", function (evt) {
            switch (evt.keyCode) {
                case dojo.keys.ENTER:
                    var searchKey = $(".txt-asset-finder").val().trim();
                    console.log("is value infinite: ", isFinite(searchKey));
                    if (searchKey.length > 3) {
                        // [0] Perform the search
                        $(".asset-search-loader").show();
                        var assetLayer = new appLayers();
                        var findAssetParams = {
                            dynamicLayerURL: assetLayer.PACKAGE_LAYERS.UTILITY,
                            layersIdsArray: [1,2,3,4,5,6,7,9,10,11,12,13,14,15,16,17,19,20,21,22,23,24,25,26,27],
                            searchFieldsArray: ["MAPREF", "Mapref", "MAINID", "Node_ID", "NODE_ID", "Map_Ref", "Main_ID"],
                            searchText: searchKey
                        };
                        when(findAsset.findDataTask(findAssetParams.dynamicLayerURL, 
                            findAssetParams.layersIdsArray, findAssetParams.searchFieldsArray,
                            findAssetParams.searchText, true), assetSearchResult_CallBack);
                    }
                    else
                        alert("please enter more than 3 characters");
                    break;
                case dojo.keys.BACKSPACE:
                    $(".assets-finder-results").html("");
                    map.graphics.clear();
                    break;
            }
        });
    }

the confusion is that this works with some values. example when I search for "A41483", I'll get the result but for "1E1105", I get the above error. I know for sure this value exists.

0 Kudos
4 Replies
KenBuja
MVP Esteemed Contributor

Is it interpreting such values as "1E1105" as a number written in scientific notation? If so, it would think the value is the number 10^1105.

0 Kudos
RichardMoussopo
Occasional Contributor III

I think you're right Ken, I tried most values starting with 1E and I get the non-finite error. how do I work around this?

0 Kudos
RichardMoussopo
Occasional Contributor III

I also tried to parse the value to string but not success!

0 Kudos
KenBuja
MVP Esteemed Contributor

I'm not sure there is a way to prevent Javascript from interpreting a string that contains a bunch of number with a single "E" in the middle of them as a number. Even something like "201E2" is interpreted as a number.  Can you strip away the numbers before or after the "E" and search on that (search for "E1105")?

0 Kudos