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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:42:35+00:00 2026-06-10T06:42:35+00:00

I try to keep data from à json file with cross domain. So i

  • 0

I try to keep data from à json file with cross domain. So i use jsonp but the file have the extension .js, so when i try $.ajax with dataType : ‘jsonp’ i have an error in console:
Uncaught SyntaxError: Unexpected token
The file is interpret as a javascript file an the request fail. Have you an idea for get data whithout this error.

$.ajax({
    url : 'http://domaine.com/file.js',
    contentType: "application/json; charset=utf-8",
    dataType : 'jsonp',
    success : function(data){
        console.log(data);
        // no enter in this callback
    },
    complete: function(data1, data2, data3){
        // no data from file.js
    }
});

I found file.js when i inspect page in scripts who are load an i can see all information, but with an error because it is considerate as javascript file.

Thanks for your help.

  • 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-10T06:42:36+00:00Added an answer on June 10, 2026 at 6:42 am

    Convert your json to proper jsonp

    jsonpcallback({"this":"is","my":"json"})
    

    Then request it with the given callback:

    <script>
        function jsonpcallback(data) {
            console.log(data);
        }
    </script>
    <script src="http://domain.com/file.js"></script>
    

    You could of course do it with jQuery too:

    $.ajax({
        url: "http://domain.com/file.js",
        dataType: "jsonp",
        jsonpCallback: "jsonpcallback",
        success: handler,
        complete: handler,
        error: handler
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try reading a JSON file from R using rjson but keep getting errors.
I try to use autocomplete jquery-ui script, but from the documentation it's explain that
I keep getting a Bad file descriptor error when I try to send data
I am getting data from log file and printing it but it was not
Working on a problem where I have to read data from a file into
I have built a site using php and want to try keep it one
I will try to keep this as simple as possible. I have a rather
So I have this problem with strings and switch-case, and I'll try to keep
As the title may suggest, I have been using jQuery AJAX to try and
I try reading data from SQL Server 2005 and filling it in a TableAdapter

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.