Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/02/2011, 15:34
Avatar de ezequiel_altamirano
ezequiel_altamirano
 
Fecha de Ingreso: febrero-2011
Mensajes: 10
Antigüedad: 13 años, 3 meses
Puntos: 1
Carrito AJAX [Urgente]

Hola amigos, tengo un problema con un carrito, que tengo que hacer. Tengo el Script Ajax, pero no tengo los datos que tengo que poner...

Osea, quiesiera que si entienden del tema, que me ayuden que es lo que tengo que hacer, si tengo que hacer una base de datos con productos, que poner, porque la verdad es que soy nuevo con Ajax.

El codigo es el siguiente:

Código:
<script type="text/javascript">
	function getRepuestos(){
		var an = $('#lsAnio').val();
		$.ajax({
			url: "ajax_repuestos.php",
			type: "GET",
			data: { an: an , a: 'get_producto'},
			success: function(datos){
				if(datos!= "" ){
					$('#div_modelo').html(datos);
					addHeightIframe($('#info').css('height'));
				}
			}
		});
	}
	
	function getPartes(t,e){
		var imagen =  e.options[e.selectedIndex].lang;
		if(imagen!=''){
				$('#imagen_respuesto').attr('src','partes/' + imagen );
				//alert($('#imagen_respuesto').attr('src'));
		}else{
			$('#imagen_respuesto').attr('src','img/elements/no_image.jpg');
		}
		
		
		$('#imagepart').show("slow");
		$('#div_pedido').css('display', 'none');
	
		
		
	
		if(t == 'producto'){
			var p = $('#listProductos').val();
			
			$('#div_parte').html(' ');
			$('#div_subparte').html(' ');
			$('#div_subsubparte').html(' ');
			
			/*var imagen = ($('#listProductos :selected').attr('lang'));*/
		}else if(t == 'partes'){
			$('#div_subparte').html(' ');
			$('#div_subsubparte').html(' ');
			var p = $('#listPartes').val();
			
		}else if(t == 'subpartes'){
			
			var p = $('#listSubpartes').val();
		}else{
			return true;
		}
		
		$.ajax({
			url: "ajax_repuestos.php",
			type: "GET",
			data: { p: p , t : t, a: 'get_partes'},
			success: function(datos){
					if(t == 'producto'){
						$('#div_parte').html(datos);
					}else if(t == 'partes'){
						$('#div_subparte').html(datos);
					}else{
						$('#div_subsubparte').html(datos);
					}			
					
					addHeightIframe($('#info').css('height'));
				
			}
		});
	}
	
	function agregarAlCarrito(valId, t){
		var cantidad = $('#txtCantidad'+ valId).val();
		var articulo = $('#'+ valId).val();
		
	//	alert(articulo);
		
		$.ajax({
			url: "ajax_repuestos.php",
			type: "GET",
			data:{
				a: 'agregar_carrito',
				cantidad: cantidad,
				articulo: articulo,
				tipo: t
			},
			success: function(datos){
				verCarrito();
			}
		});	
	}
	
	
	function limpiarPedido(){
		$.ajax({
			url: "ajax_repuestos.php",
			type: "GET",
			data:{
				a: 'limpiar_carrito'
			},
			success: function(datos){ //alert(div_id + datos);
				verCarrito();
			}
		});	
	}


	function eliminarItem(id){
		$.ajax({
			url: "ajax_repuestos.php",
			type: "GET",
			data:{
				a: 'eliminar_producto',
				id: id
			},
			success: function(datos){ //alert(div_id + datos);
				verCarrito();
			}
		});	
	}
	
	function modItem(id,t){
		$.ajax({
			url: "ajax_repuestos.php",
			type: "GET",
			data:{
				a: 'agregar_carrito',
				cantidad: t,
				articulo: id
			},
			success: function(datos){ //alert(div_id + datos);
				verCarrito();
			}
		});	
	}


	function verCarrito(){
		$.ajax({
			url: "ajax_repuestos.php",
			type: "GET",
			data:{
				a: 'ver_carrito'
			},
			success: function(datos){ //alert(div_id + datos);
				$('#div_Carrito').html(datos);
				
				var aaa = $('#info').css('height');
				
				addHeightIframe(aaa.replace('px',''));
				
			}
		});	
	}
	
	
	function addHeightIframe(h){
		if(window.parent.document.getElementById('iframe')){
			window.parent.document.getElementById('iframe').height = parseInt(h) + 50;
		}
	}
	
	function enviarPara(para){
	if(para == 'amigo'){
		$('.para_amigo').css("display","block");
		$(".para_dealer").css("display","none");
	}else{
		$(".para_amigo").css("display","none");
		$(".para_dealer").css("display","block");
	}	
	
}
	
	function enviarPedido(){
		$.ajax({
			url: "ajax_repuestos.php",
			type: "GET",
			data:{
				a						: 'enviar_pedido',
				enviopara 				: $("input[name='enviopara']:checked").val(),
				envioSuEmail 			: $('#envioSuEmail').val(),
				envioSuNombre 			: $('#envioSuNombre').val(),
				envioEmailDestinatario 	: $('#envioEmailDestinatario').val(),
				envioComentario 		: $('#envioComentario').val(),
				regionDealer 			: $('#regionDealer').val(),				
			},
			success: function(datos){ //alert(div_id + datos);
				document.getElementById('formariopedido').reset();
				$('#div_mensajeenvio').html(datos);
			}
		});	
	
		
		if(document.getElementById('limpiar_check').checked == true){
			limpiarPedido();	
		}
	}
	function realizarPedido(){
		$('#div_pedido').show("slow");
		$('#imagepart').css('display', 'none');
	}
	
	$().ready(function() {
		getRepuestos();
		verCarrito();
		/*alert($(window).height());*/
	});
</script>

Les agradeceria mucho que me ayuden!!!