Ver Mensaje Individual
  #3 (permalink)  
Antiguo 29/03/2009, 13:35
AngelJ
 
Fecha de Ingreso: febrero-2009
Mensajes: 35
Antigüedad: 15 años, 2 meses
Puntos: 0
Respuesta: Ajax a PHP y luego a JavaScript

Gracias por tu colaboración pero he rastreado los archivos .js y no he encontrado ninguna función onload en uso... Para tratar de daros información más precisa sobre el problema, os introduciré parte del código:

Este es el código javascript con el que empleo para incrustar el flash:

Código js:
Ver original
  1. function insertaSWF(archivo, ancho, alto, alineacion, wmode, quality, allowScriptAccess) {
  2.  
  3. if(alineacion!=""){
  4. var alineacion_data=alineacion;
  5. }else{
  6. var alineacion_data="center";
  7. }
  8.  
  9. if(wmode!=""){
  10. var wmode_data=wmode;
  11. }else{
  12. var wmode_data="transparent";
  13. }
  14.  
  15. if(quality!=""){
  16. quality_data=quality;
  17. }else{
  18. quality_data="high";
  19. }
  20.  
  21. if(allowScriptAccess!=""){
  22. allowScriptAccess_data=allowScriptAccess;
  23. }else{
  24. allowScriptAccess_data="sameDomain";
  25. }
  26.  
  27. //Comprobamos versión del navegador
  28. if(document.all){//Si es Internet Explorer "quitamos el atributo DATA que no le gusta a IE".
  29. document.write('<object type="application/x-shockwave-flash" width='+ancho+' height='+alto+' align='+alineacion_data+'>\n');
  30. }else{//Si es Firefox
  31. document.write('<object type="application/x-shockwave-flash" data='+archivo+' width='+ancho+' height='+alto+' align='+alineacion_data+'>\n');
  32. }//Fin si
  33. document.write('<param name="allowScriptAccess" value='+allowScriptAccess_data+' />\n');
  34. document.write('<param name="movie" value='+archivo+' />\n');
  35. document.write('<param name="quality" value='+quality_data+' />\n');
  36. document.write('<param name="wmode" value='+wmode_data+' />\n');
  37. document.write('</object>\n');
  38. }

Con este script puedo visualizar el flash sin problema cuando hago llamadas "naturales" al archivo, ejemplo:
Cita:
myweb/index.php?mod=loquesea

Sin embargo cuando hago las llamadas a partir de AJAX para evitar la recarga de la web entera, no se me ejecuta el flash, el efecto es el mismo que si cortara el script que lo llama:

Cita:
<a href="index.php?mod=loquesea" onclick="processajax ('index.php?mod=loquesea','main','get',''); return false;">Page 1</a>
Este es el archivo de ajax sobre el que trabaja la función:

Código js:
Ver original
  1. //xmlhttp.js
  2.    
  3.     //Function to create an XMLHttp Object.
  4.     function getxmlhttp (){
  5.         //Create a boolean variable to check for a valid microsoft active X instance.
  6.         var xmlhttp = false;
  7.        
  8.         //Check if we are using internet explorer.
  9.         try {
  10.             //If the javascript version is greater than 5.
  11.             xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  12.         } catch (e) {
  13.             //If not, then use the older active x object.
  14.             try {
  15.                 //If we are using internet explorer.
  16.                 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  17.             } catch (E) {
  18.                 //Else we must be using a non-internet explorer browser.
  19.                 xmlhttp = false;
  20.             }
  21.         }
  22.        
  23.         //If we are using a non-internet explorer browser, create a javascript instance of the object.
  24.         if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
  25.             xmlhttp = new XMLHttpRequest();
  26.         }
  27.        
  28.         return xmlhttp;
  29.     }
  30.    
  31.     //Function to process an XMLHttpRequest.
  32.     function processajax (serverPage, obj, getOrPost, str){
  33.         //Get an XMLHttpRequest object for use.
  34.         xmlhttp = getxmlhttp ();
  35.         if (getOrPost == "get"){
  36.             xmlhttp.open("GET", serverPage);
  37.             xmlhttp.onreadystatechange = function() {
  38.                 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  39.                     document.getElementById(obj).innerHTML = xmlhttp.responseText;
  40.                 }
  41.             }
  42.             xmlhttp.send(null);
  43.         } else {
  44.             xmlhttp.open("POST", serverPage, true);
  45.             xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
  46.             xmlhttp.onreadystatechange = function() {
  47.                 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  48.                     document.getElementById(obj).innerHTML = xmlhttp.responseText;
  49.                 }
  50.             }
  51.             xmlhttp.send(str);
  52.         }
  53.     }

Y esto creo que más o menos es todo, espero haber planteado el problema con más precisión.

Saludos.