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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:12:48+00:00 2026-06-07T12:12:48+00:00

fnServerData: function( sUrl, aoData, fnCallback, oSettings ) { oSettings.jqXHR = $.ajax( { url: sUrl,

  • 0
"fnServerData": function( sUrl, aoData, fnCallback, oSettings ) {
            oSettings.jqXHR = $.ajax( {
                "url": sUrl,
                "data": aoData,
                "success": fnCallback,
                "error":function(msg){
                    alert(msg);
                },
                "dataType": "jsonp",
                "cache": false
            } );
        },

When I make that request, server gives that response.

Status Code: 200 OK
Cache-Control: max-age=0
Content-Language: en
Content-Type: application/javascript
Expires: Thu, 12 Jul 2012 06:23:18 GMT
Last-Modified: Thu, 12 Jul 2012 06:23:18 GMT
Vary: Accept-Language, Cookie

And a json data in Response body.

But ajax code says it has an error, and going into “error” code block.

Why it is giving error while its status is 200?

UPDATE:

In Django server code:

            response_dict = {}                
            response_dict.update({'aaData': aaData})
            response_dict.update({'sEcho': sEcho, 'iTotalRecords': iTotalRecords, 'iTotalDisplayRecords':iTotalDisplayRecords, 'sColumns':sColumns})
            response = HttpResponse(simplejson.dumps(response_dict), mimetype='application/javascript')
  • 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-07T12:12:52+00:00Added an answer on June 7, 2026 at 12:12 pm

    Does the server response contain JSON with padding?

    You see, there are two ways to receive data from different domain:

    1. CORS is the new one but requires a separate Access-Control-Allow-Origin header to be sent from the server. Browser support is also somewhat limited for it.

    2. JSONP doesn’t rely on a server header but instead requires it to send back JSON data with so-called ‘padding’:

      callback('{"your": ["json", "data"}')
      

      Your JavaScript library (jQuery in this case) is then wraps it into a new script tag tricking your browser to evaluate it. Inside this callback function jQuery parses the JSON data and sends it to your fnCallback. After that it removes the unnecessary script tag from the page. In general it’s a very fragile solution but it works in practice. For example, if the server doesn’t pad JSON data you’ll end up with the following code inside a script tag:

      '{"your": ["json", "data"}'
      

      Notice that it’s just a string and does nothing. So, check if the server sends the wrapped JSON and not the raw JSON. I’ve run into the same problem quite a few times before and that helped me.


    EDIT: Since you posted your server-side code I assume that you can modify it. I’ve never played with Django but I’ll try to give you hints:

    1. Inside the request that you receive there should be a parameter called callback – that’s what jQuery sends to you and what you should use for padding. Put it somewhere:

      # Like I said I don't know the exact API but you get the idea
      callback = request.GET["callback"]
      
    2. After that pad your response before sending it to client:

      response = HttpResponse( # Put callback name before the actual JSON
                     callback + "(" + simplejson.dumps(response_dict) + ");", 
                     mimetype='application/javascript')
      

    This should work.

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

Sidebar

Related Questions

I'm using DataTables ( datatables.net ) to display data from an Ajax source and
I initialised my table like this /* POST data to server */ $(document).ready(function() {
I am trying to bind Asp.Net Repeater Control for Ajax Data using DataTables Plugin
I'm currently using datatables with ajax data and I want do adjust the column
I am trying to implement a function on jquery datatable, that returns the 1st
i have a data table..but it can't select one row after click the row..
In jquery DataTables it is possible to add server parameters through the method fnServerData
I don't know if it's a bug, but I have a datatable+ajax with the
I am using DataTables plugin to fetch and paginate my table use ajax calls.
I am using jQuery DataTables and doing server-side data. I'm trying to call a

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.