简体   繁体   English

Java脚本未调用函数

[英]Java Script Not Calling A function

I am creating a solution(web resource) for My CRM project. 我正在为我的CRM项目创建解决方案(网络资源)。 For that purpose i have written a map optimization code in java script using Bing API. 为此,我使用Bing API用Java脚本编写了地图优化代码。

retrieveAccountsCallBack is retrieving addresses from the CRM. retrieveAccountsCallBack正在从CRM中检索地址。 I am then using those address to find their Geo Codes. 然后,我使用这些地址查找其地域代码。 Problem is when the code reaches to point map.getCredentials(MakeGeocodeRequest) it is then not going into the definition Of map.getCredentials(MakeGeocodeRequest) function . 问题是,当代码到达指向map.getCredentials(MakeGeocodeRequest)它就没有进入map.getCredentials(MakeGeocodeRequest)函数的定义了。 It just passes this line like its commented out . 它就像注释掉了一样通过了这条线。 But here is the twist some times it works but there is no definite pattern. 但是有时候这是可行的,但是没有确定的模式。

Here is the code: 这是代码:

function retrieveAccountsCallBack(retrievedAccounts) {

        totalAccountCount = totalAccountCount + retrievedAccounts.length;

        for (var i = 0; i < retrievedAccounts.length; i++) {

            var account = retrievedAccounts[i];
            //retLoc.push(account.new_address);
            waypoint = retrievedAccounts[i].new_address;
            map.getCredentials(MakeGeocodeRequest);
            ///////////////////////////////////////////

        }


    }

Code for MakeGeocodeRequest() MakeGeocodeRequest()的代码

 function MakeGeocodeRequest(cred) {

        var geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations?query=" + encodeURI(waypoint) + "&output=json&jsonp=GeocodeCallback&key=" + cred;
        CallRestService(geocodeRequest);
    }

Finally i figured it out!!!! 终于我想通了! After thorough reading of Bing Maps API. 仔细阅读Bing Maps API之后。 i came to to know that there it was happening due to some anonymous functions in that API which i was not able to understand as it was written in compressed java script code. 我知道它的发生是由于该API中的一些匿名函数所致,因为它是用压缩的Java脚本代码编写的,所以我无法理解。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM