Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/04/2014, 14:31
skandar
 
Fecha de Ingreso: enero-2011
Mensajes: 24
Antigüedad: 13 años, 10 meses
Puntos: 1
colocar dato de jquery en variable

Hola, tengo conocimientos básicos, por lo que la respuesta puede ser simple, pero no he dado con ella:

El problema es el siguiente:
De un JQuery puedo fácilmente colocar un dato en un ID o Clase (de un div) de un php, pero lo que necesito es colocar un dato en una variable (donde no puedo darle id o clase), los códigos son los siguientes:

Jquery:

Código:
jQuery(document).ready(function() {
    pollstation();
    //refresh the data every 10 seconds
    setInterval(pollstation, 10000);
});

// Accepts a url and a callback function to run.  
function requestCrossDomain( callback ) {  
    // Take the provided url, and add it to a YQL query. Make sure you encode it!  
    var yql = 'yql.php?callback=?';
    // Request that YSQL string, and run a callback function.  
    // Pass a defined function to prevent cache-busting.  
    jQuery.getJSON( yql, cbFunc );
  
    function cbFunc(data) {  
    // If we have something to work with...  
    if ( data ) {  
        // Strip out all script tags, for security reasons. there shouldn't be any, however
        data = data[0].results.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, '');
        data = data.replace(/<html[^>]*>/gi, '');
        data = data.replace(/<\/html>/gi, '');
        data = data.replace(/<body[^>]*>/gi, '');
        data = data.replace(/<\/body>/gi, '');
  
        // If the user passed a callback, and it  
        // is a function, call it, and send through the data var.  
        if ( typeof callback === 'function') {  
            callback(data);  
        }  
    }  
    // Else, Maybe we requested a site that doesn't exist, and nothing returned.  
    else throw new Error('Nothing returned from getJSON.');  
    }  
}  

function pollstation() {
    requestCrossDomain(function(stationdata) {
        //make our data into an array
        var lines = stationdata.split('<br/>');
        
        //update number of listeners
        jQuery('#listeners').html(lines[0]);          

        //transform the song title into [artist] - [title] ([year])
        s_info=lines[1].split(" - ");
        
        //remove the artist from the title
        title=jQuery.trim(s_info[1]);          
      
        //update the album art
        jQuery('#songsearch').html('<img src="http://dominio.com/suena/imagen.php?tema=' + encodeURIComponent(jQuery.trim(s_info[0])) + '" />');  
        
        //update the album art
        jQuery('#nombre').text('' + encodeURIComponent(jQuery.trim(s_info[0])) + ''); 
        
        //remove the year from the title
        cleantitle=jQuery.trim(s_info[1].replace(/\ \(\d{4}\)/,''));
        
        //keep just the year
        new_year=title.replace(cleantitle, '');
        
        //get rid of parenthesis around the year
        new_year=new_year.replace(/\ \(/,'');
        new_year=new_year.replace(/\)/,'');
        
        //if a special show, let's identify it and properly format it
        var index = cleantitle.indexOf("[Aural Pleasure]");
        if(index != -1) {
            //remove the show title from the title of the song
            cleantitle=cleantitle.replace(/\ \[Aural Pleasure\]/,'');
            
            //replace the year with the song
            new_year='Aural Pleasure';
            
            //update the album art for the show
            jQuery('#songsearch').html('<img src="http://www.dominio.com/templates/atom/images/fondo/header/logo-centro.jpg" alt="" />');
        }
        
        //update the current artist and song title
        jQuery('#currentsong').html('<span style="font-weight:bold;color:#993333;font-size: 14px;">' + jQuery.trim(cleantitle) + '</span><br /><span id="tema-imagen" style="font-weight:bold;color:#333333;font-size: 12px;"><em>' + jQuery.trim(s_info[0]) + '</em></span><br /><div style="font-weight:bold;font-size: 14px;">' + jQuery.trim(new_year) + '</div>');
        
        //update the previously played songs
        for (var i = 1; i <= 10; i++) {            
            jQuery('#prevsong' + i).html('<a href="http://dominio.com/redirect.php?song=' + encodeURIComponent(jQuery.trim(lines[i+1])) + '" title="view song information"  style="text-decoration:none;font-weight:normal" target="_blank">' + lines[i + 1] + '</a>');
        }
    } );
}
El dato que necesito es de jQuery('#nombre')

PHP:

Código PHP:
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="pollstation.js" type="text/javascript"></script>
<style>
body {
    color:#000;
}
</style>
</head>
<body>

Al Aire:
<div id="currentsong"></div>
<div id="nombre"></div>

<br />
<div>
<?php
require_once "LastFM.php";

$artwork LastFM::getArtwork("$tema"true"extralarge");


if(
$artwork) {
    echo 
$artwork;
}
?>

<br />
<span id="listeners"></span>
<br /><br />
Ultimos temas:
    <ul>
    <li><span id="prevsong1"></span></li>
    <li><span id="prevsong2"></span></li>
    <li><span id="prevsong3"></span></li>
    <li><span id="prevsong4"></span></li>
    <li><span id="prevsong5"></span></li>
    <li><span id="prevsong6"></span></li>
    <li><span id="prevsong7"></span></li>
    <li><span id="prevsong8"></span></li>
    <li><span id="prevsong9"></span></li>
    </ul>
</body>
</html>
Necesito colocar el dato en la variable $tema que esta dentro de un (), ¿de que manera puedo extraer el dato del jquery y colocarlo ahí?