sajax, php, entities, JS and IE
Well.... it's plenty of stuff.
I'm making an LDAP browsing application for our enterprise (web enabled). It's made on PHP. I have already displayed the directory and can collapse / expand nodes. I have implemented node expansion with ajax (via sajax). In the PHP function that is called to get the information of the nodes I'm going to display I pass some information, like: Node's Plain Name Node's DN Node's GUID If the node has children among others. I separate each line by a \n and each node by an empty line (\n). The JS code "parses" that input that's coming from sajax and creates the nodes and so on. It works flawlessly..... on firefox. Not that it fails on IE, it works there too... but it fails when I have a html entity in my code (that I'm not decoding on php). Things like "Enfermería" make the script fail from that point on. Here's one output that the browser is supposed to handle (through my script that gets its input from sajax): Code:
+:var res = 'a9d6d489976453488534e1188af6c956\n17\norganizationalunit \nAdiestramiento y Soporte\nOU=Adiestramiento y Soporte,OU=AIT,DC=FHEP,DC=ORG\n79560207a9c609438c5ad54d5cd641ff\ntrue\n\ngroup \nAnalista Web\nCN=Analista Web,OU=AIT,DC=FHEP,DC=ORG\n74cabd037763dc46a14ee777c25d4716\nfalse\n\norganizationalunit \nAnalista Web y Movil\nOU=Analista Web y Movil,OU=AIT,DC=FHEP,DC=ORG\nd0171519e267974095ce80065c80e430\nfalse\n\ngroup \nAplicacion Evaluaciones\nCN=Aplicacion Evaluaciones,OU=AIT,DC=FHEP,DC=ORG\n4c37585469b6c44598c8391be0dd7634\nfalse\n\ngroup \nAsesores\nCN=Asesores,OU=AIT,DC=FHEP,DC=ORG\nb6724ee1757bbc4d946713e457bba72c\nfalse\n\norganizationalunit \nAsesores SMILE\nOU=Asesores SMILE,OU=AIT,DC=FHEP,DC=ORG\n10bd2391ffb09f4f81e0d9914f605de8\ntrue\n\norganizationalunit \nCoordinacion de AIT\nOU=Coordinacion de AIT,OU=AIT,DC=FHEP,DC=ORG\n453e3eec097c7749bd5c9d036f799d51\ntrue\n\ngroup \nCoordinador de Sistemas\nCN=Coordinador de Sistemas,OU=AIT,DC=FHEP,DC=ORG\n4e9f8a768873eb47b8ffb76ecf680564\nfalse\n\norganizationalunit \nDigitalizaci�\nOU=Digitalizaci�,OU=AIT,DC=FHEP,DC=ORG\nef0d3df10db09f43ba76860f23e7e5b4\ntrue\n\norganizationalunit \nHardware\nOU=Hardware,OU=AIT,DC=FHEP,DC=ORG\n44606e18a8e7fe4db253b76b297ca433\ntrue\n\ngroup \nInforme de Errores SMILE\nCN=Informe de Errores SMILE,OU=AIT,DC=FHEP,DC=ORG\ne151e7eb1e6eb0489161\nfalse\n\ngroup \nPasante de Sistemas\nCN=Pasante de Sistemas,OU=AIT,DC=FHEP,DC=ORG\nb58bcb05975e6c4da0b92c028d543fc7\nfalse\n\ngroup \nSistemas Global\nCN=Sistemas Global,OU=AIT,DC=FHEP,DC=ORG\n25d1b4547518ed4abd65fa9a0dc72950\nfalse\n\norganizationalunit \nSoftware\nOU=Software,OU=AIT,DC=FHEP,DC=ORG\ne782dc21e66d0a4f9fd20d5ee508a852\ntrue\n\ngroup \nSoporte Administrativo\nCN=Soporte Administrativo,OU=AIT,DC=FHEP,DC=ORG\n80ab950ee499f74b8814e59a861e32fb\nfalse\n\norganizationalunit \nSoporte ASYS\nOU=Soporte ASYS,OU=AIT,DC=FHEP,DC=ORG\n9a612d71fe89314e9e04285f72e7a59e\ntrue\n\ngroup \nSoporte SMILE\nCN=Soporte SMILE,OU=AIT,DC=FHEP,DC=ORG\n3451e868f980ec47b316c2789432c58e\nfalse\n\n'; res; Code:
63 69 F3 6E This is the JS code I use to parse the input and create the nodes: Code:
function agregarNodos(resultado) { Any ideas how I can overcome the problem? |
I have noticed that IE, when it finds say: {á, é, í, ó, ú, ñ}, it will "skip" processing the following 2 characters. So Médica (por example) doesn't fail (though it shows up like "M?ca", but "Enfermería" at the end of one string will, because the \n will be processed as Enfermer?n and then continue with whatever follows just like it's a single line.
Well.... Do I have to blame M$? Or it's normal behavior? Any idea how I can better parse it then? |
Solved it: on PHP (sajax side) I have to process this strings with non 7-bit ascii characters through rawurlencode() and then on the JS side use unescape() to get them back the way they were originally. :-) It worked on IE and on FF. :-D
|
All times are GMT -5. The time now is 10:16 PM. |