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

The Archive Base Latest Questions

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

$.ajax({ beforeSend: function(xhr) { xhr.setRequestHeader(‘Authorization’, Basic YWRtaW46YWRtaW4=); }, url: https://test.com/incident.do?JSON&callback=?&sysparm_action=getRecords, dataType: json, contentType: application/json,

  • 0
       $.ajax({
  beforeSend: function(xhr) {
 xhr.setRequestHeader('Authorization', "Basic YWRtaW46YWRtaW4=");        
},
   url: "https://test.com/incident.do?JSON&callback=?&sysparm_action=getRecords",
   dataType: "json",
   contentType: "application/json",
   method: 'GET',
   success: function(a,b,c) { 
    alert(a);
         }          
 });

I call this function with a button press… Firebug shows that I get this JSON response (which I know is valid) [truncated for clarity]

{
    "records": [
        {
            "service_offering": "",
            "number": "INC0000009"
        },
        {
            "service_offering": "",
            "number": "INC0000010"
        }
]
}

Firebug shows the error “invalid label
https://test.com/incident.do?JSON&callback=jsonp1279049933243&sysparm_action=getRecords
Line 1

How can I fix this?
Thanks!

  • 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-15T18:48:34+00:00Added an answer on May 15, 2026 at 6:48 pm

    Your response is JSON, which is valid, but that’s not what jQuery’s looking for. When you specify &callback=? in the URL, jQuery is expecting a JSONP response, which looks different, your response should be

    jsonp1279049933243({
      "records": [
        {
            "service_offering": "",
            "number": "INC0000009"
        },
        {
            "service_offering": "",
            "number": "INC0000010"
        }
      ]
    });
    

    What happens when you specify callback=? is that jQuery generates a name for your success function, in this case jsonp1279049933243, JSONP works by just generating a <script> tag in the page, so when it fetches that url, it’s really just including a JavaScript file, running a function, but instead of this:

    <script type="text/javascript">
      jsonp1279049933243({ "records": [....] });
    </script>
    

    What’s effectively happening now is:

    <script type="text/javascript">
      { "records": [....] }
    </script>
    

    …which isn’t valid JavaScript. Now of course it’s loaded via src=https://test.com/incident.do?JSON&callback=jsonp1279049933243&sysparm_action=getRecords, but the invalid syntax/label error is the same.

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

Sidebar

Related Questions

$.ajax({ method: post , url: save.php , data: id=453&action=test , beforeSend: function(){ } ,
Code: $.ajax({ type: POST, url: students/login, data:{data[Student][email]:_email,data[Student][password]:_password},ss beforeSend: function(){ $(#confirm).text(); }, error: function (xhr,
For example, i'm using the beforeSend option in the $.ajax function. In the code
ajax tutorial on w3school at http://www.w3schools.com/ajax/ajax_database.asp In this function (function GetXmlHttpObject()), it creates a
I am using a web service that returns JSON data. test.com/incident.do?JSON&sysparm_action=getRecords Loading this URL
What is the use of beforeSend Function in jQuery Ajax? How to use the
I have the following Ajax call: function ajaxCall(soap, url){ // Post SOAP request. $.ajax({
We have a web applet that loads under the URL https://secure-ausomxeja.crmondemand.com/OnDemand/ ... from where
Has anyone had the same experiences with jQuery AJAX and the beforeSend property? Any
Is there any way to terminate ajax execution, based on beforeSend result ? $.ajaxSetup({

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.