Ver Mensaje Individual
  #3 (permalink)  
Antiguo 28/06/2012, 09:51
amelper
 
Fecha de Ingreso: mayo-2012
Ubicación: ISLAS CANARIAS
Mensajes: 5
Antigüedad: 12 años, 4 meses
Puntos: 0
Respuesta: Enviar con JQUERY mediante JSONP variables para procesar en un PHP

Al final no he logrado el hito marcado empleando integramente JQuery, dado que la put-ada del crossdomain es muy gorda.

Por tanto he empleado una mezcla de mi primer source con el nuevo.

Código Javascript:
Ver original
  1. function QJ()
  2. {
  3.     //Variables generales
  4.     var IP        = '192.168.56.3';
  5.     var urlclip   = 'http://'+IP+'/almacenar.db.php';
  6.     var divid     = 'UT'+Math.round(Math.random()*1000000);
  7.  
  8.     //Obtenemos el texto seleccionado
  9.     x = document.createElement('div');
  10.     x.appendChild(window.getSelection().getRangeAt(0).cloneContents());
  11.  
  12.     //Extraemos todo el Tag HEAD
  13.     var head      = document.getElementsByTagName('head')[0];
  14.  
  15.     //Agregamos fichero JQuery
  16.     var jquery    = document.createElement('script');
  17.     jquery.type   = 'text/javascript';
  18.     jquery.src    = 'http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js';
  19.  
  20.     //Agregamos fichero JQuery-UI (.dialog)
  21.     var jqueryui  = document.createElement('script');
  22.     jqueryui.type = 'text/javascript';
  23.     jqueryui.src  = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js';
  24.  
  25.     head.appendChild(jquery);
  26.     head.appendChild(jqueryui);
  27.  
  28.     jquery.onload = function()
  29.     {
  30.         jqueryui.onload = function()
  31.         {
  32.             var ptu=function(vars)
  33.             {
  34.  
  35.                 var div = document.createElement('div');
  36.  
  37.                 div.id            = divid+'FATHER';
  38.                 div.innerHTML     = '<iframe></iframe>';
  39.  
  40.                 document.body.appendChild(div);
  41.  
  42.                 var ifram = div.firstChild;
  43.                 var iframe = ifram.contentDocument || ifram.contentWindow.document;
  44.                 iframe.open();
  45.                 iframe.close();
  46.  
  47.                 var form = iframe.createElement('form');
  48.                 iframe.body.appendChild(form);
  49.  
  50.                 form.setAttribute('method','post');
  51.                 form.setAttribute('action',urlclip);
  52.  
  53.                 for(var k in vars)
  54.                 {
  55.                     var input = iframe.createElement('input');
  56.                     input.setAttribute('type','hidden');
  57.                     input.setAttribute('name',k);
  58.                     input.setAttribute('value',vars[k]);
  59.                     form.appendChild(input);
  60.                 }
  61.                 form.submit();
  62.             };
  63.  
  64.             ptu(
  65.             {
  66.                 a:'YES',
  67.                 q:escape(x.innerText),
  68.                 u:location.href,
  69.                 t:escape(document.title),
  70.                 i:divid
  71.             });
  72.         }
  73.     }
  74. }

Ahora voy a intentar adjuntar a este fichero un .DIALOG que abra un iframe 100% y este llame a un fichero externo.