user3763124 user3763124 - 1 year ago 69
HTML Question

Getting \n returned in jquery and not sure why

I created a site a month ago at work and there is a section where I get the user's IP address and current location and display it. It was working fine up until I went on the website today and the location part is no longer working.

The IP returns the proper IP but for the location returns: \n

This is what i see:

Detected IP Address: the correct IP

Location: \n, \n (instead of city, state)

I asked the few people at work who have access to the code and they all told me they never touched anything.

Anyone know what happened, that can just cause code to seemingly just stop working overnight?


<div class="warning-info">
Detected IP address: <span class="yellow" id="ip"></span><br>
Location: <span class="yellow" id="address"></span><br><br>

Jquery code

$.get("", function (response) {
$("#address").html( + ", " + response.region);
}, "jsonp");

Answer Source

On the site page, they recommend to use $getJSON, you can try the following:

    $.getJSON('', function(data){
      $("#address").html( + ", " + data.region);

This piece of code is working on my local environment(Apache+PHP)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download