ArcGIS Server JS development, a strange problem (the dojo is undefined and the machine name cannot be accessed)

Source: Internet
Author: User

Recently, we are developing ArcGIS Server Js. The js api is deployed on the local machine and accessed by the machine name. The access code is as follows.

    1. <SCRIPT type = "text/JavaScript" src = "http: // myserver/arcgis_js_api/library/2.1/ArcGIS /? V = 2.1 "> </SCRIPT>
    2. <SCRIPT type = "text/JavaScript">
      Dojo. Require ("ESRI. Map ");
      Dojo. Require ("ESRI. toolbars. Edit ");
      Dojo. Require ("ESRI. layers. featurelayer ");
      Dojo. Require ("dijit. Form. checkbox ");
      VaR map;
    3. </SCRIPT>

Myserver is the machine name of the local machine, and the program runs normally after work on Friday. When I came to work on Monday, the error "dojo undefined" occurred !!

Enter the URL in the browser: http: // myserver/arcgis_js_api/library/2.1/ArcGIS /? V = 2.1 can access API resources. Strange, why is the program wrong ??

After a long time, I thought about re-installing the system. Alas, it was such an inexplicable and wonderful mistake to reinstall the system. The cost was too high and the reason was not found. Maybe I will encounter it one day later. There must be a solution. Use exclusion. Based on the error, there are two possible reasons: First, JavaScript APIs are not loaded at all. Second, there is a program error. Therefore, the following method is used to exclude:

Copy a demo program from the ArcGIS website to vs2005 and run it. You can access the map correctly. Then, change the API reference address to the local, running, and the same error. This indicates that the program itself should be fine. The problem lies in that the API on the local machine cannot be accessed.

Then I thought about deploying an API on another machine and accessing it through the local machine. Yes, this is a good way. As a result, the API is configured on another machine and accessed on the local machine. Visit the local browser first, and enter http: // machine name of the other party /............ Results, cannot access !!! So, ping the machine name of the other machine, and the machine name is not pingable. Oh, the problem is found: the machine cannot access other machines through the machine name !!!!

Then, when accessing the js api of the local machine, it is accessed by the machine name of the local machine, and ping the machine name of the local machine can be pinged, accessing the machine name on the local machine through a browser is also accessible. Why cannot I access the machine name on the local machine when the program is running ??????

The problem now becomes: The machine name cannot access resources of other machines !!!

So I went to the hundreds of times and found out why I couldn't access other machines through the machine name. I checked for half a day and failed. Someone finally reminded me if your subnet mask is incorrect ??? Oh, check it out:

255.255.0.0 ???? (Local mask)

Let's look at other people in the same LAN:

They have 255.255.255.0 !!!!

Change the mask of the Local Machine to 255.255.255.0. A series of problems have been solved !!!!!

Conclusion: After the subnet mask of the local machine is changed, the local machine can access the Internet through the gateway, access other machines through IP addresses, and access its own machines through machine names.

However, problems occur when ArcGIS API calls a program and accesses the API on the local machine through the machine name. It is estimated that "<SCRIPT type =" text/JavaScript "src =" http: // myserver/arcgis_js_api/library/2.1/ArcGIS /? V = 2.1 "> </SCRIPT>" when accessing the local machine, the local API is accessed through the vro. As a result, the resource cannot be found due to the incorrect subnet mask. Therefore, there is a difference between "accessing resources on a machine through proxy" and "accessing resources on a machine through a browser. This is precisely the difference that will lead to and cover up a system's inexplicable errors.

Imagine that if the subnet mask is set incorrectly and the local machine is unplugged from the Internet, the program runs properly, because the access does not need to go through the router, and the relevant resources can be accessed through the machine name.

A small mistake wasted me half a day searching and writing this blog to show my memory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.