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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:49:47+00:00 2026-06-17T16:49:47+00:00

I have the following Jquery callback function and I have a litle doubt about

  • 0

I have the following Jquery callback function and I have a litle doubt about it (I don’t know very well Jquery):

$("form.readXmlForm").submit(function() {
    // Riferimento all'elemento form che ha scatenato il submit 
    var form = $(this);
    // Variabile che contiene il riferimento al bottone clickato 
    var button = form.children(":first");

    $.ajax({        // Viene eseguita la chiamata AJAX 
        type: "POST", // Tipo di richiesta: POST 
        // URL verso quale viene inviata la richiesta
        url: form.attr("action"),    
        // Dati XML inviati: 
        data: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><javaBean><foo>bar</foo><fruit>apple</fruit></javaBean>", 
        // Tipo di media type accettabile dalla response: 
        contentType: "application/xml", 
        dataType: "text", 

        success: function(text) { 
            MvcUtil.showSuccessResponse(text, button); 
        }, 

        error: function(xhr) { 
            MvcUtil.showErrorResponse(xhr.responseText, button); 
        }
    });

As you can see this function simply execute an AJAX Request to the backend setting the parameter for this request.

I have set that I am sending the request towards an URL, that the request is a POST request and that the data that I am sending are the following string:

“barapple”

I have some difficulties to understand what is the differences between contentType and dataType

I think that contentType specify the type of data that are acceptable recived in the HTTP Response, is it right?

And dataType? What say? The type of data that I am sending in the HTTP Request?

In this case is is “text” because I am sending a textual string that rappresent XML code?

  • 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-17T16:49:47+00:00Added an answer on June 17, 2026 at 4:49 pm

    From the documentation:

    contentType (default: ‘application/x-www-form-urlencoded; charset=UTF-8’)

    Type: String

    When sending data to the server, use this content type. Default is "application/x-www-form-urlencoded; charset=UTF-8", which is fine for most cases. If you explicitly pass in a content-type to $.ajax(), then it’ll always be sent to the server (even if no data is sent). If no charset is specified, data will be transmitted to the server using the server’s default charset; you must decode this appropriately on the server side.

    and:

    dataType (default: Intelligent Guess (xml, json, script, or html))

    Type: String

    The type of data that you’re expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string).

    They’re essentially the opposite of what you thought they were.

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

Sidebar

Related Questions

I have the following jquery: jQuery.fn.slideFadeToggle = function(speed, easing, callback) { return this.animate({ opacity:
I have the following jQuery code: $(.save_button).click(function() { var $form = $(this).closest(div.info_section).find(form); url =
i have the following jQuery code. $(function() { $('.clickme').click(function() { $('.totalthing').slideToggle('slow','easeInOutQuart', function() { //
I have the following jquery script: $(function(){ $('#top-menu').on('click', 'a.change-menu', function(e){ e.preventDefault() $(#menu-change-div).load($(this).attr(href)); }); });
I have the following jquery code: $(document).ready(function() { $(body[class*=page-calendar-practices] #content-header h1#title).after(<div id='athletics_practice-schedule'><div id='inner-title'><a href='www.example.com'
I have the following jquery function that submits to an iframe. The message sent
I have the following jQuery code: var isUsernameAvailable = false; function CheckUsername(uname) { $.ajax({
I have the following code jQuery.getJSON(encodeURI(strUrl), {address:address,state:state, zip:zip},function(data){ alert('HELLO World!'); }); If for some
I have the following use of jQuery UI function: $('.droppable').droppable({ tolerance: 'touch', over: function
I think this should be simple. Say I've got the following jQuery: $someForm.live('submit', function(event)

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.