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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:59:18+00:00 2026-05-29T11:59:18+00:00

I’m making a cross-domain AJAX request using jQuery but my callback function is not

  • 0

I’m making a cross-domain AJAX request using jQuery but my callback function is not firing (see http://jsfiddle.net/zC8z5/).

function jsonpCallback(response){
    $('#code').text(response.data);
}

$.ajax({
    url: url,
    dataType: 'jsonp',
    error: function(xhr, status, error) {
        alert(error);
    },
    success: function() {
        alert("success");                            
    },
    jsonp: false,
    jsonpCallback: 'jsonpCallback'
});

As per the docs:

As of jQuery 1.5, setting the jsonp option to false prevents jQuery
from adding the “?callback” string to the URL or attempting to use
“=?” for transformation. In this case, you should also explicitly set
the jsonpCallback setting. For example, { jsonp: false, jsonpCallback:
“callbackName” }

However, if I don’t specify a callback and instead just handle the data in the success event it works (see http://jsfiddle.net/2gBRT/).

$.ajax({
    url: url,
    dataType: 'jsonp',
    error: function(xhr, status, error) {
        alert(error);
    },
    success: function(data) { 
        jsonpCallback(data);
    }
});

Have I misunderstood how to make JSONP requests with jQuery?

  • 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-29T11:59:20+00:00Added an answer on May 29, 2026 at 11:59 am

    As noted in the docs you excerpted, if the server expects a parameter called callback, jQuery is smart enough to fill in the blank for you. Bitbucket does use this parameter name, so you get a URL like:

    https://api.bitbucket.org/.../?callback=jquery1234_5678
    

    jquery1234_5678 would actually be an automatically generated function name for your callback. Bitbucket then returns something like:

    jquery1234_5678({
        "node": "someId",
        "path": "filename",
        "data": "content"
    })
    

    so the function is called. Also, you can simplify (demo) the success part to:

    success: jsonpCallback
    

    If Bitbucket expected a different parameter name, you would use that as the value of jsonp. So for example, if you passed:

    jsonp: "functionName"
    

    the URL would look something like:

    https://api.bitbucket.org/.../?functionName=jquery1234_5678
    

    but the response would be the same.

    You only need jsonpCallback if you don’t want jQuery to generate the function name.

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

Sidebar

Related Questions

I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I
I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.