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 ?? 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? |}   

then 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.

Note: Check the line even after comment with " * *". I'm not sure that the line is correct. Two }} .

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -