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

  • Home
  • SEARCH
  • 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 7186085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:33:28+00:00 2026-05-28T18:33:28+00:00

I am using jsonp and ajax to access a web service on another server.

  • 0

I am using jsonp and ajax to access a web service on another server. Here’s the jQuery:

$.ajax({
  type: 'GET',
  url: wsurl + 'callback=?',
  dataType: 'jsonp',
  crossDomain: true,
  error: function(data) {
    console.log('error', data);
  },
  success: function(data) {
    console.log('success', data);
  },
  complete: function() {
    console.log('done');
  }
});

The issue is that the error callback is being called. It gives me this wonderfully helpful information:

{
  readyState: 4,
  status: 200,
  statusText: "success"
}

And here is the json file I am calling:

{
  "id": 0,
  "room_number": "0",
  "first_name": "Admin",
  "last_name": "Istrator",
  "password": "",
  "salutation": "Mr.",
  "telephone": "",
  "email": "",
  "description": "admin",
  "checkin_date": 915797106000,
  "checkout_date": 4071557106000,
  "last_login_date": 947333106000,
  "active_status": true,
  "created_date": 915797106000,
  "created_by": 0,
  "reference_id": ""
}

I tried using the getJSON jQuery method first, with the same result. Thought I’d try the base ajax method, since it has a bit more control, but as you can see, no luck. So, notice anything I’m doing wrong? Have any idea why it is throwing an error and giving me a successful value for the statusText property?

EDIT

Alright, I added some options to the ajax call, and removed the callback param from the url. Here’s the new ajax call:

  $.ajax({
    type: 'GET',
    url: wsurl,
    dataType: 'jsonp',
    crossDomain: true,
    error: function(xhr, textStatus, errorThrown) {
      console.log('textStatus: ' + textStatus);
    },
    success: function(data) {
      console.log('success');
      console.log(data);
    }
  });

I’m getting a new error, which is good I suppose, but still not working. Difference is that the textStatus is now “parsererror”. The console is also throwing a syntax error on line one of the json file:

Uncaught SyntaxError: Unexpected token :

Ideas?

  • 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-28T18:33:29+00:00Added an answer on May 28, 2026 at 6:33 pm

    Okay a couple of things jump out at me:

    $.ajax({
      type: 'GET',
      #You do not need to append the callback as you have jsonp configured it will  do it    
      #automatically append the callback=<auto generated name>
      url: wsurl, 
      dataType: 'jsonp',
      crossDomain: true,
      error: function(data) {
        console.log('error', data);
      },
      success: function(data) {
        console.log('success', data);
      },
      complete: function() {
        console.log('done');
      }
    });
    

    Also your return does not to appear to be wrapped in a function which is required for jsonp to work.

    <auto generated name>({ json object })
    

    The callback function will be named by jquery automatically. So you need a service that will take in a callback parameter and return a json object with padding.

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

Sidebar

Related Questions

I plan on using JSONP to call an external web service to get around
I'm using jquery to access a asp.net web service from my website. This web
What is the difference between using: $.ajax({ type: 'POST', url: Drupal.settings.basePath + 'module/get/' +
I'm having difficulty parsing some JSON data returned from my server using jQuery.ajax() To
I'm currently using jquery ajax to call a pagemethod (which works great); $.ajax({ type:
I am using jQuery to consume a web service I built, the input is
So here is my problem. I'm using Jquery's $.ajax to pass back a series
How would you access the cache from a jQuery ajax call? I'm using jquery
I'm unable to successfully post using jquery's ajax functionality. URL of the running page
We are using the Dynamic Script Tag with JsonP mechanism to achieve cross-domain Ajax

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.