jquery - Ajax geolocation how to show error if person refuses to give location -
If someone accepts requests to show their location then it works but if I try and find out That the user did not find me anything if the person refused then I want to post, so I have a record. This is code, it does not show any error, if I refuse to give my position, I think the error: function () will work ?? then Note: Check the line even after comment with " * *". I'm not sure that the line is correct. Two function getCoordPosition () {if (navigator.clocation) {navigator.geolocation.getCurrentPosition (function () {$ .ajax ({type: "POST", url: "{{path ( 'Login_log_location')}}, data: {latitude: position.coords.latitude, longitude: position.coords.longitude}, success: work () {$ ("# divputinarea"). Html ('& lt; form method = Post action = "path ('login_log_yourerea')}} button> class =" btn btn-big btn-primary "> find your nearest match & lt; / button & gt; ');}, error: work Html ('error found');}}}}})}} description is false;}
There is also a
error function in which the
PositionError is the parameter. To retrieve that information, there is also a
error function in the avigator.Aviewing.GetContrap (success, error, option) For example
function getCoordPosition () {if navigator.geolocation} {navigator.geolocation.getCurrentPosition (function () {$ .ajax ({type: "POST", Url: "{{path ('login_log_location')}}, data: {latitude: position.coords.latitude, longitude: position.coords.longitude}, success: work () {// **** $ (" # Divputinarea "). Html ('& lt; form method = post action = "path (' + login_log_yourarea + ')}}"> button class = "btn btn-big btn-primary"> close closest match / button & Gt;);}, Error: Action () {$ ("# divputinarea") Html ('Error found');}}}}, function (error) {console.log ('failed:'); Console.log (error); If (error.code == 1) {console.log (error.message); // do something!}}); } return false; Object object written in the console:
status error {message: "User denied geolocation", code: 1, PERMISSION_DENIED: 1, POSITION_UNAVAILABLE: 2, TIMEOUT: 3a? |}
error. Message is
user has rejected geolocation . See also for the clarification code value is
PERMISSION_DENIED : failed to acquire the geographic information because the page was not allowed to do this.
}} .
Comments
Post a Comment