Eventsource NetworkError:406不可接受

时间:2018-01-06 06:24:49

标签: c# jquery eventsource

当使用Eventsource请求json文件时,我得到 NetworkError:406 Not Acceptable 。代码如下。

 var source = new EventSource('/liveMap/pesron1.json');

                    source.addEventListener("open", function (event) {
                        console.log('Processing started...')
                    }, false);


                    source.addEventListener("error", function (event) {
                        if (event.eventPhase == EventSource.CLOSED) {
                            console.log('error...')
                            source.close();
                        }
                    }, false);

                    source.addEventListener("message", function (event) {
                        console.log('data ', event.data)
                        var data = JSON.parse(event.data);
                    }, false);

json文件是geojson,如下所示:

{"type":"FeatureCollection","features":[{"type":"Feature","id":"1850220292","geometry":{"type":"Point","coordinates":[51.4220625,35.7131196]},"properties":{"id":"1850220292","Description":"","Url":"liveMap/3131.json","Date":"1396/10/07  12:40:08","Accuracy":"19.573","Bearing":"0","Speed":"0","Direction":"0","GPSState":"0","PowerState":"0","Latitude":"35.7131196","Longitude":"51.4220625","BusinessName":"m-Ali","LocationName":""}}]}

0 个答案:

没有答案