Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8898163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:32:34+00:00 2026-06-15T00:32:34+00:00

I’m trying to get data from Geobytes. One of the templates returns JSON and

  • 0

I’m trying to get data from Geobytes. One of the templates returns JSON and I need to cross-domain access it.

I wrote these 2 functions

function getCountry(ip) {
    var surl = "http://www.geobytes.com/IpLocator.htm?GetLocation&template=json.txt";
    $.ajax({
        url: surl,
        data: '{"ipaddress":"' + ip + '"}',
        dataType: "jsonp",
        processData: false,
        jsonpCallback: "jsonpcallback",
        error: function (xhr, status, error) {
            alert(xhr.responseText);
        }
    });
}

function jsonpcallback(rtndata) {
    alert(rtndata.message);
}

The call is executed successfully, these are my response headers:

HTTP/1.1 200 OK
Date: Sat, 17 Nov 2012 12:43:54 GMT
Expires: 0
Content-type: text/html
Transfer-Encoding: chunked

the returned data is JSON, but I get

warning: Resource interpreted as Script but transferred with MIME type text/html: "http://www.geobytes.com/IpLocator.htm?GetLocation&template=json.txt&callback=jsonpcallback&{%22ipaddress%22:%22200.167.254.166%22}&_=1353148931121"

Error on the remote IpLocator.htm: Uncaught SyntaxError: Unexpected token :

The error is thrown on the returned data at

{"geobytes":{"countryid":117,

I think is maybe because it’s 117 and not "117" but I obviously can’t control the returned data. Tried to add a "processData=false" but that didn’t help.

I’ve added the error handling to the ajax and get "parsererror" on the status

How can I fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:32:35+00:00Added an answer on June 15, 2026 at 12:32 am

    Thank you to no.andrea for pointing me to the right direction!

    As I’m using MVC3 I’ve added a new controller

    [HttpPost]
    public JsonResult JsonGetCountry(string ip)
    {
        try
        {
            var sb = new StringBuilder();
            sb.Append("http://www.geobytes.com/IpLocator.htm?GetLocation");
            sb.Append("&template=json.txt");
            sb.Append("&IpAddress=");
            sb.Append(ip);
    
            var webClient = new WebClient();
            var data = webClient.OpenRead(sb.ToString());
    
            if (data == null) { return Json(""); }
    
            var reader = new StreamReader(data);
            var msg = reader.ReadToEnd();
            data.Close();
            reader.Close();
    
            return Json(msg);
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message, ex);
        }
    }
    

    and updated my JQuery function to

    function getCountry(ip) {
        $.ajax({
            type: "POST",
            url: "/My-Shop/IP/JsonGetCountry",
            data: '{"ip":"' + ip + '"}',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                var a = $.parseJSON(msg);
                alert(a.geobytes.iso2);
            },
            error: function (ex) {
                alert(ex.statusText);
        }
    });
    

    And that fixed all my problems 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.