html5 地址标记,HTML5 GeoLocation地址表填充程序未捕获的SyntaxError:意外的标记

HTML5 GeoLocation地址表填充程序未捕获的SyntaxError:意外的标记

一般来说,我是新手。

我不断收到

“未捕获的SyntaxError:意外的令牌

xhr.open("GET", url);

xhr.onload = function() {

//if we make a successful request and it returns an address

if(this.status==200 && JSON.parse(xhr.responseText).contents.results.length > 0){

//get formatted address from https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding

var result = JSON.parse(xhr.responseText).contents.results[0].formatted_address;

putInDom(result);

} else {

//send some general error

info.innerHTML = "Could not find your location.";

}

}

I'm new to coding in general.

I keep getting the

"Uncaught SyntaxError: Unexpected token

xhr.open("GET", url);

xhr.onload = function() {

//if we make a successful request and it returns an address

if(this.status==200 && JSON.parse(xhr.responseText).contents.results.length > 0){

//get formatted address from https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding

var result = JSON.parse(xhr.responseText).contents.results[0].formatted_address;

putInDom(result);

} else {

//send some general error

info.innerHTML = "Could not find your location.";

}

}

Here's where I get the zip file from. I appreciate all helps. Thank you. http://techslides.com/html5-geolocation-address-form-filler

原文:https://stackoverflow.com/questions/34430165

更新时间:2020-01-21 22:01

最满意答案

看起来您的回答是HTML,而不是JSON。 因此JSON.parse在< token上抛出一个SyntaxError 。

Looks like your response is HTML, not JSON. Therefore JSON.parse is throwing a SyntaxError on the < token.

相关问答

我在modules.json上的路径上有一个错误,纠正了我的模块和指令的路径解决了问题 "ui/module",

"ui/directives/ExtensibleNavBarDirective"

I had an error on my paths on modules.json, correcting the path to my module and directive resolved the issues "ui/module",

"ui/directives/Exte

...

该错误消息表示JavaScript语法错误。 您引用的代码是XHTML,它不是JavaScript。 试图将其视为JavaScript(正如您所做)注定要失败。 这可能是由于在src属性中输入了错误的URL。 The error message indicates a JavaScript syntax error. The code you quoted is XHTML, which is not JavaScript. Trying to treat it as JavaScript (as

...

JavaScript使用else if not elseif 。 JavaScript uses else if , not elseif.

浏览器在请求a.config.js时看到了什么? 也许有一些URL重写涉及。 What does the browser see when it requests a.config.js? Maybe there is some URL rewriting involved.

语法问题。 尝试这个: $("#ride").append('

p><p>+%20'

'

+ snapshot.val().user

+ '

...

onXYZ属性风格的处理程序是为了一步一步的代码; 浏览器将它们封装在一个函数中。 所以onXYZ处理程序最终会是这样的: function onclick(event) {

function() {

checkQuestion(check);

}

}

您可以看到问题:生成的函数的内容无效。 所以如果使用onXYZ处理程序,它应该是: btn.setAttribute("onclick", "return checkQuestion(check);");

..

...

我认为问题在于您使用的errorTextFormat的实现。 data参数是jqXHR对象,它是XMLHTTPRequest对象的超集。 两者都支持getResponseHeader方法,您可以使用该方法检测来自服务器的响应是否包含JSON数据或其HTML数据。 所以你可以测试类似的东西 errorTextFormat: function (data) {

var contentType = xhr.getResponseHeader("Content-Type");

if (ty

...

尝试从head标签中删除runat="server"

Merchants TotalView

Try removing the runat="server" from the head tag

Merchants TotalView

...

看起来您的回答是HTML,而不是JSON。 因此JSON.parse在< token上抛出一个SyntaxError 。 Looks like your response is HTML, not JSON. Therefore JSON.parse is throwing a SyntaxError on the < token.

在您的服务中删除; 在第一行。 angular.module( '起始');

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值