1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| /*******************************/
function sendAjaxForm(form, script, divcible){
var url = 'ajax/'+script;
alert (form+'-'+script+'-'+divcible);
lesvars = $(form).serialize(true); // retourne {param1: 'test', param2: 'test2'}
$('response').innerHTML = '';
var myAjax = new Ajax.Request(
url,
{
method: 'post',
asynchronous: false,
contentType: 'application/x-www-form-urlencoded',
encoding: 'UTF-8',
parameters: lesvars,
onLoading: function (xhr)
{ // Création de l'objet XHR
$(divcible).innerHTML = '<img src="images/icons/loading.gif" />';
},
onSuccess: function (transport)
{ // Réponse HTTP == 2xx
$(divcible).innerHTML = transport.responseText ;
$('form_avantde').hide();
},
on404: function (xhr)
{ // Réponse HTTP "OK"
$(divcible).innerHTML = 'HTTP 404 "Not Found"<br /><br />';
},
onFailure: function (xhr)
{ // Réponse HTTP != 2xx
$(divcible).innerHTML = 'Failure : '
+ xhr.status + ' :' + xhr.statusText + '<br /><br />';
},
onException: function (xhr, exception)
{
$(divcible).innerHTML = 'Exception : ' + exception + '<br />';
}
});
} // gestionClic() |
Partager