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
|
(function($){
/********************************************************************/
// $infoWindow : fenetre modale qui est affichée pendant le chargement
// url : addresse de la page a charger
// success : function(data), fonction executée lors de la réception des données
$.findProduct = function($infoWindow, url, success, options){
var defauts = {
"timeout": 3000
};
var myOptions = $.extend(defauts, options);
var $div = $infoWindow.find(".modal-body");
$infoWindow.find(".modal-header h3").text("Informations");
$div.empty().append($('<div class="alert">Produit en cours de redémarrage...</div>'));
$infoWindow.find(".modal-footer button").addClass("hide");
$infoWindow.modal("show");
var $ajax = $.ajax({
url: url,
dataType: "json",
type: "GET",
cache: false,
timeout: myOptions.timeout,
error: function(){
$.findProduct(this.$infoWindow, this.url, this.success, this.options);
// => on relance la requete car produit non detecté
// probleme : this.success est vide => pourquoi ?
},
//data: postStr,
context: {$infoWindow:$infoWindow, url:url, succes:success, options:options},
success: function(data){
this.succes(data);
this.$infoWindow.modal("hide");
}
});
return $ajax;
};
})(jQuery); |