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 9154853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:29:47+00:00 2026-06-17T12:29:47+00:00

I have a url which gives json data… I want to hit that URL

  • 0

I have a url which gives json data…

I want to hit that URL from javascript but I am getting this error :

character encoding of the plain text document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the file needs to be declared in the transfer protocol or file needs to use a byte order mark as an encoding signature

Code :

function a(){
$.getJSON(url,function(data) { alert(data);});
}

full code :

<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" ></meta>
<script language="JavaScript" type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script>

function a(){
$.getJSON(url,function(data) { alert(data);});
}
</script>
</head>
<body>
<input type="text"/>
<input type="submit" value="search" onclick="a()"/>
</body>
</html>
  • 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-17T12:29:48+00:00Added an answer on June 17, 2026 at 12:29 pm

    Your code seems correct.

    Are you making a fully qualified URL call?

    If you are making a fully qualified URL call, make sure of the following.

    1. You are calling the same domain(same server). You can not make a
      simple JSON call to another domain.
    2. If you want to use a cross domain call, you’ll have to use JSONp

    Update:
    This is not working since it is a cross domain call.

    Work around for this

    JavaScript

    Create a function

    function getMyData(data) {
        alert(data);
        //Do the magic with your data
    }
    

    Server side

    On server end wrap your data inside function syntax

    getMyData("Enter your data here");
    

    JavaScript

    Then create a script tag and add a link to your cross-domain page

     <script type="text/javascript"
             src="cross ref url">
     </script>
    

    For reference: wikipedia

    EDIT: Another option is Create a proxy on your domain. ie create a page in your domain which internally calls the cross-domain page and return the same data to your Ajax call.

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

Sidebar

Related Questions

Hi have this URL string which I need to extract possibly using regex but
I want to make customer route for url which have parameters. <a href='javascript:void(0)' onclick=window.location='<?php
I have a url which serves data to my android application, i learnt from
I have a perl script URL which gives me a ZIP file, it processes
I have a url which have a response in Json lon=-0.1275&pg=0 I parsed the
i have this code in my view which is in a loop which gives
I have a jQuery call like this, which gives me a lot of problems:
I have a jquery script in my file that says this: <script type=text/javascript> $(document).ready(function(e){
i have a working example which uses this url http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=jQuery16201154390876987067_1314382298849&tags=cat&tagmode=any&format=json&_=1314382298856 which gives me this
I have a JavaScript file which has a function that I reference. When I

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.