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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:58:18+00:00 2026-06-04T07:58:18+00:00

I have a simple JQuery Stockwatcher app, which makes a JSONP request but the

  • 0

I have a simple JQuery Stockwatcher app, which makes a JSONP request but the callback function is not getting called. I have the JSON call for this app working, but at somepoint it is going to be cross domain, hence I have to make is JSONP.

What am I doing wrong? When I run this code, the Error function gets called.

function loadData(data) {
    alert("Load Data");
    $.each(data.stocks,function(i,item){
        $("#results").append('Title:'+item.symbol+' ==  Price:'+item.price+'</p>');
    });
}   

$(document).ready(function(){
var url='http://localhost:8080/StockWatcherServer/stockwatcher/stockPrices?q=';
var query;
    $('button').click(function(){
        query=$("#query").val();
        // Assign handlers immediately after making the request,
        // and remember the jqxhr object for this request

        //$.ajaxSetup({ crossDomain: true, scriptCharset: "utf-8" , contentType: "jsonp; charset=utf-8"});
        $.ajax({
            url : url+query,
            type: "GET",
            dataType: "jsonp",
            jsonp : "callback",
            jsonpCallback: "loadData",
            success: function(data) {alert("Success");},
            error: function(data) { alert("Error"); },

            });        
       });
});

Here is my JSON Output, which I can see in Firebug

{"stocks": [
  {
    "symbol": "IPOD",
    "price": 20.2182603350167,
    "change": 0.3128265006354697
  }
]}

Thanks
Rajesh

  • 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-04T07:58:19+00:00Added an answer on June 4, 2026 at 7:58 am

    That is JSON, not JSONP. If you are doing cross-domain JSON request, it must be JSONP not JSON. Different port is cross-domain.

    This is the JSONP that your request should be returning based on your code. Additionally, your loadData method will be overridden by jquery IIRC.

    loadData({"stocks": [
      {
        "symbol": "IPOD",
        "price": 20.2182603350167,
        "change": 0.3128265006354697
      }
    ]})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple jquery/ajax request to the server which returns the structure and
I have written a simple jQuery.ajax function which loads a user control from the
I have a simple jquery function which I use to show/hide some divs. The
i have a simple Jquery code which is for sending $.ajax request and passing
I have a simple JQuery function that makes a DIV's content scroll sideways, endlessly.
I have a simple jquery animation on a div, which is inside a div,
I have a simple Jquery function here: function submit_selection(del,submit) { del='yes'; submit=true; var ITAMZ=new
I have the following simple jquery snippet $(document).ready(function () { $.ajax({ url:myjson.json, dataType: 'json',
I have a simple bit of jQuery which displays the row below the current
I have a simple JQuery enabled ASP.NET page: <script> $(document).ready(function() { $(#accordion).accordion(); }); </script>

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.