从Weather.asmx中检索数据进入错误路径-Javascript

时间:2014-08-08 08:52:44

标签: javascript jquery ajax web-services

我想从Weather.asmx中检索一些数据并在下面编写代码来获取一些数据。 Javascript没有出现任何错误,但是当程序运行时,它总是转到groupPropertiesErrorHandler函数。有什么想法吗?

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('#butCallAjax').click(function() {
            jQuery.support.cors = true;
            $.ajax({
                url: "http://wsf.cdyne.com/WeatherWS/Weather.asmx/GetCityWeatherByZIP?ZIP=10007",
                method: "GET",
                headers: {
                    "Accept": "application/json; odata=verbose"
                },
                success: groupPropertiesSuccessHandler,
                error: groupPropertiesErrorHandler
            });
        });

        function groupPropertiesSuccessHandler(data) {
            var jsonObject = JSON.parse(data.body);
            var properties = 'Group Properties:\n';
            alert(properties);
        }

        // Error Handler
        function groupPropertiesErrorHandler(data, errorCode, errorMessage) {
            alert("Could not get the group properties: " + errorMessage);
        }
    });
</script>

0 个答案:

没有答案