enmi12/glossaire/js/ajax.js
changeset 0 d970ebf37754
equal deleted inserted replaced
-1:000000000000 0:d970ebf37754
       
     1 function xmlRequest(event){		
       
     2 		var req = null; 
       
     3 		//document.ajax.dyn.value="Started...";
       
     4 		
       
     5 		if (window.XMLHttpRequest)
       
     6 		{
       
     7  			req = new XMLHttpRequest();
       
     8 			if (req.overrideMimeType) 
       
     9 			{
       
    10 				req.overrideMimeType('text/xml');
       
    11 			}
       
    12 		} 
       
    13 		else if (window.ActiveXObject) 
       
    14 		{
       
    15 			try {
       
    16 				req = new ActiveXObject("Msxml2.XMLHTTP");
       
    17 			} catch (e)
       
    18 			{
       
    19 				try {
       
    20 					req = new ActiveXObject("Microsoft.XMLHTTP");
       
    21 				} catch (e) {}
       
    22 			}
       
    23 	        	}
       
    24 
       
    25 
       
    26 		req.onreadystatechange = function()
       
    27 		{ 
       
    28 			//var loadingContent = 
       
    29 			//$('.commentSection').append('
       
    30 			if(req.readyState == 4)
       
    31 			{
       
    32 				if(req.status == 200)
       
    33 				{
       
    34 					// process a XML document here	
       
    35 
       
    36 					var xml = req.responseXML;
       
    37 					$xml = $(xml);
       
    38 					var mot = $(event.target).first().parents('div[data-mot]').attr('data-mot');
       
    39 					var typologie = $(event.target).first().parents('div[data-mot]').attr('class');
       
    40 					
       
    41 					typologie = typologie.replace(/(arsIndustrialis|discipline|thematique|vulgarisation) /gi, '');
       
    42 					
       
    43 					console.log(typologie);
       
    44 					
       
    45 					var commentaires = $xml.find('mot[name]').filter(function() {return removeAccents($(this).attr("name").toLowerCase()) == mot;});
       
    46 					var typologieComment = commentaires.children();
       
    47 
       
    48 				}	
       
    49 				else	
       
    50 				{
       
    51 					alert("Error: returned status code " + req.status + " " + req.statusText);
       
    52 				}	
       
    53 			} 
       
    54 		}; 
       
    55 		req.open("GET", "comments.xml", true); 
       
    56 		req.send(null); 
       
    57 }