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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:10:30+00:00 2026-05-27T14:10:30+00:00

I am trying to make an ajax call and it returns something like, a

  • 0

I am trying to make an ajax call and it returns something like, a JSON object;

{
id: 6,
success: "true"
}

My ajax call is :

window.foobar = function(foo){
    $.ajax({
            url: "http://foobar.com/sites/foo/",
            dataType: "jsonp",
            success: function (data) {
        alert(data);
            },
            error: function () {
            }
        });
}

This ajax call is cross site call.
On chrome it gives: Uncaught SyntaxError: Unexpected token :
On firefox it gives:

invalid label
http://localhost:8080/sites/foo/?callback=jsonp1324336100888&_=1324336100894
Line 1

But when I calling from the same domain it works fine.

  • 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-05-27T14:10:30+00:00Added an answer on May 27, 2026 at 2:10 pm

    If you are claiming to support JSONP, you need to actually support it. Your code is valid JSON, but it is not valid Javascript: a response to a JSONP request must be valid Javascript. (To be precise, your code is invalid because the {} delimit a block, rather than an object literal.)

    If you implement JSONP, you need to wrap the data in a call to a function whose name is given in the URL, in the callback parameter. So in this case, you need to post the following code:

    jsonp1324336100888({
    id: 6,
    success: "true"
    });
    

    Obviously the precise name of the function you need to call depends on the callback URL parameter.

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

Sidebar

Related Questions

I trying to make my first AJAX with JSON call using jQuery and CodeIgniter.
Im trying to make a function return a string from a ajax call. This
My trying to make an Ajax call to a PHP function that pulls out
I'm trying to make an ajax call to grab session data to insert into
I am trying to make two ajax requests in parallel using jQuery like this:
I am trying to make an ajax call to a php script. The php
Trying to make a call and retrieve a very simple, one line, JSON file.
I am trying to make a ajax call to other domain locally from my
I am trying to make an ajax call using jquery in my spring MVC
I'm trying to make an Ajax call on all <a> elements inside the id

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.