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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:26:46+00:00 2026-06-04T09:26:46+00:00

I have created a jQuery ajaxTransport handler (for some testscases I have) that is

  • 0

I have created a jQuery ajaxTransport handler (for some testscases I have) that is supposed to simulate a 403 validation error on the server.

The problem is that when I do this and return a 403 error, the data is not returned, not as json and not as responseText.

Here is my code (simplified): (also on jsfiddle http://jsfiddle.net/znTCL/1/)

$.ajaxTransport('json',function( options, originalOptions, jqXHR ) {
    return {
      send: function( headers, completeCallback ) {
        completeCallback(403, 'Forbidden', {json : {'Title': 'Title is required.'}});
      }
    };
});

$(function() {

    $.ajax({
        url :document.location,
        type : 'POST',
        data : {Title:''},
        dataType : 'json'                   
    }).fail(function(){ 
        console.log(arguments);
    });
});

If I return a 403 for real on the server and don’t use ajaxtransports, then everything works as expected, the fail callback have the jqXHR object that also contains the responseText that I can then parse as JSON and then show validation errors based on that. With ajaxtransports the jqXHR object have no reponseText property.

If I return a 200 in the transport, the data comes along as it should and responseText is as it should.

Am I doing anything wrong or is this a limitation of jQuery ajaxTransports?
​

  • 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-04T09:26:49+00:00Added an answer on June 4, 2026 at 9:26 am

    It seems you can’t return json to the completeCallback when you return an error. Even though your request was a json request.

    Returning text works:

    completeCallback(403, 'Forbidden', {text : 'Title is required.'});
    

    Or

    completeCallback(403, 'Forbidden', {text : JSON.stringify({'Title': 'Title is required.'})});
    

    Now responseText of the jqXHR object in the fail callback is not undefined, it contains the text I supply and I can now parse it.

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

Sidebar

Related Questions

I have created some JQuery that on click of specified HTML it then becomes
I have created a form that must pass validation via JQuery to see if
I have created a jQuery elastic plugin. I have the problem that if I
I have created a jQuery animation that can be seen by clicking the Preview
I have created a simple JQuery script with hovering effect on some links. The
I have created a dynamic list picker script using Jquery 1.3 and PHP that
I have created a drop down with jQuery that can be seen here by
I have added JQUERY Galleria a site that I have created but am having
I have created some jQuery and put it in an ascx include. It works
Here is my problem: The Problem I have created Tabs using jQuery which is

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.