Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Guardar en DB con Ajax

Estas en el tema de Guardar en DB con Ajax en el foro de Frameworks JS en Foros del Web. Hola amigos, veran estoy usando un script en ajax que me permite hacer esto: http://digitalhymn.com/argilla/tipmage/ En una parte del código dice esto: @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código ...
  #1 (permalink)  
Antiguo 09/08/2009, 18:03
 
Fecha de Ingreso: septiembre-2007
Ubicación: PyRoot
Mensajes: 1.515
Antigüedad: 16 años, 7 meses
Puntos: 188
Guardar en DB con Ajax

Hola amigos, veran estoy usando un script en ajax que me permite hacer esto:

http://digitalhymn.com/argilla/tipmage/


En una parte del código dice esto:

Código js:
Ver original
  1. /**
  2.      *  It can be used to save the tooltip in a database with AjAX.
  3.      *  @param  identifier  An identifier (ID) that may be useful for a database
  4.      *  @param  posx    X coordinate of the tooltip rectangle after editing
  5.      *  @param  posy        Y coordinate of the tooltip rectangle after editing
  6.      *  @param  width   Width of the tooltip rectangle after editing
  7.      *  @param  height  Height of the tooltip rectangle after editing
  8.      *  @param  text        Text contained in the tooltip after editing
  9.      */
  10.     'onInsert' : function (identifier,posx,posy,width,height,text) {
  11.         // do nothing - this is just a stub
  12.     },

Me pueden ayudar a entender como puedo guardar en la DB la "etiqueta" (la posicion en X, la posicion en Y, etc... de la imagen,

Muchas gracias

EDITO:

COMO MAYOR REFERENCIA ECONTRE ESTO:

[hr]
Advanced operations

Tipmage provides tools to create and edit tooltips, but they would be pretty useless without a way to give them persistence (for example saving them in a database). To gain persistence we will use callback functions.

Tipmage provides 3 function stubs: onInsert, onUpdate and onDelete. These functions will be called automatically by the engine with the right parameters, which are: ID of the tooltip, horizontal and vertical position of the rectangle, width and height of the rectangle and the text attached to the tooltip.

By implementing the stubs, we can make Tipmage do what we want with our data.

Let's see an example illustrating how to implement the onInsert function. This code should go in the same place as the code showed above.
Código js:
Ver original
  1. <script type="text/javascript">
  2.   tipmage.onInsert = function (identifier,posx,posy,width,height,text) {
  3.     // do something, like an AJaX call or whatever...
  4.   };
  5. </script>

onInsert is called when a new tooltip is added, onUpdate is called when an existing tooltip is modified, onDelete is called when an existing tooltip is deleted.

__________________

Si entiendo el ingles, pero no se nada sobre como agregar a la DB con Ajax, muchas gracias.
__________________
Si quieres agradecer el triangulo obscuro de la parte derecha debes presionar +.
  #2 (permalink)  
Antiguo 09/08/2009, 22:06
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Guardar en DB con Ajax

Te recomiendo leer las FAQs del foro para que entiendas como hacer un request asíncrono a un archivo PHP, una vez que entiendas como hacer el request de forma asíncrona solamente tienes que agregarselo a tu código y podrías almacenar lo que necesites, por ejemplo si usaras JQuery, harías algo así:
Código Javascript:
Ver original
  1. <script type="text/javascript">
  2.   tipmage.onInsert = function (identifier,posx,posy,width,height,text) {
  3.          $.post('file.php', {identifier: identifier, posx: posx, posy: posy: width: width: height:height, text:text}, function( response ) {
  4.        alert( 'la respuesta es: ' + response );
  5. }
  6.   });
  7. </script>

Luego solo sería crear un archivo php (file.php por ejemplo) y var a recibir las variables por $_POST, como $_POST['posx'], las almacenas en una base de datos y solo respondes un "ok" o algo por el estilo para la respuesta AJAX.

Saludos.

Última edición por GatorV; 10/08/2009 a las 11:33
  #3 (permalink)  
Antiguo 09/08/2009, 23:59
 
Fecha de Ingreso: septiembre-2007
Ubicación: PyRoot
Mensajes: 1.515
Antigüedad: 16 años, 7 meses
Puntos: 188
Respuesta: Guardar en DB con Ajax

muchas gracias, muy completa la respuesta.

Entonces imagino que aqui inicio en mi aprendizaje AJAX.

GRacias saludos!
__________________
Si quieres agradecer el triangulo obscuro de la parte derecha debes presionar +.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:29.