I have the following jQuery callback function, and I have doubts about this (I don't know jQuery very well):
$("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 for server-side parameter setting for this request.
I found that I am sending the request at the URL, that the request is a POST request, and that the data I'm sending is the following line:
"barapple"
I have some difficulties to understand what are the differences between contentType and dataType
I think contentType indicates the data type acceptable for the HTTP response, right?
And dataType? What to say? The type of data I send in an HTTP request?
In this case, is it βtextβ because I am sending a text string that contains XML?
javascript jquery ajax
AndreaNobili Jan 14 '13 at 16:57 2013-01-14 16:57
source share