Ver Mensaje Individual
  #5 (permalink)  
Antiguo 10/07/2015, 11:48
mensajeescrito
 
Fecha de Ingreso: mayo-2012
Mensajes: 760
Antigüedad: 12 años
Puntos: 5
Respuesta: pasar valor de variable php mediante ajax

ufff, ufff, a ver, a ver:

He hecho esto:

archivo 1:

Código PHP:
Ver original
  1. if (isset($_POST['enviar'])) {
  2.        
  3.         if (is_array($_POST['categoria'])) {
  4.        
  5.                 $selected = '';
  6.                 $num_categoria = count($_POST['categoria']);
  7.                 $current = 0;
  8.    
  9.                 foreach ($_POST['categoria'] as $key => $value) {
  10.                         $selected .= $value.'';
  11.                                                                
  12.                     $current++;
  13.        
  14.                 }
  15.             }                                          
  16.         }
  17.        
  18.         else
  19.        
  20.         {
  21.             $selected = 'tienda_novedades';
  22.                            
  23.         }


Código Javascript:
Ver original
  1. $.ajax({
  2.  
  3. $.post('data.php', {selected:<?php $value ?>}, function(data){
  4. $("#tienda").append(data);
  5. console.log(data);
  6.  
  7. });



archivo 2 llamado data.php

Código PHP:
Ver original
  1. $requested_page = $_POST['page_num'];
  2.         $set_limit = (($requested_page - 1) * 12) . ",12";
  3.        
  4.         $con = mysql_connect("localhost", "root", "");
  5.         mysql_select_db("bbdd");
  6.        
  7.        
  8.        $result = mysql_query("select * from $selected order by id asc limit $set_limit");


realmente en archivo 2 no pongo nada es simplemente lo que tengo en php.


Pero no funciona , sigue sin funcionar

helppppp