Reply
Load Javascript Array Created By Php And Execute!
Old 11-03-2009, 02:08 PM Load Javascript Array Created By Php And Execute!
evans123's Avatar
Ultra Talker

Posts: 350
Trades: 0
I use a php file to generate a javascript array, so when i include it in the file it executes the javascript ok! But when i try and use jquery to reload the file after a minute it doesn't work and won't execute the javascript any ideas on a similar idea or fix?
__________________
SoldierExteme.com - Free MMORPG - sign-up today!
Backthebulls.com - Free online games (mad_willsy's)
Msnextra.co.uk - Msn Items

Last edited by evans123; 11-03-2009 at 02:09 PM..
evans123 is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 11-03-2009, 02:39 PM Re: Load Javascript Array Created By Php And Execute!
wayfarer07's Avatar
NYE-KEE

Posts: 3,155
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Using PHP has no bearing on how or why JavaScript executes, so forget that part of the question. All that is left, is what does the client-side code look like (what is output to the browser)?
__________________
Wayfarer | jQuery Tooltip Plugin | Mapbox: the jQuery Map
Freelance Jobs Available
If Google is the Coca-Cola of Web search, Bing is RC Cola
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 11-03-2009, 02:51 PM Re: Load Javascript Array Created By Php And Execute!
evans123's Avatar
Ultra Talker

Posts: 350
Trades: 0
PHP Code:
<?php 
    
include("config.php");

$pagePost 1;
$match mysql_fetch_array(mysql_query("SELECT * FROM `manager__fixtures` WHERE `id` = '" $pagePost "'"));
$information = array();
// Time
$time $match['kick_off'];
$match_time = (($match['day'] * 86400) + $_SESSION['season_start']);
$output strtotime(date("dS F Y $time"$match_time)) + 5400;
if(
time() > $output)
{
$information["minute"] = "| <strong>R</strong>";
} else {
$information["minute"] = "| <strong>" . (90 floor(($output time()) / 60)) . " min</strong>";

if(
time() > $output
{
$min 90;
} else {
$min = (90 floor(($output time()) / 60));
}

//Score
$home_score mysql_num_rows(mysql_query("SELECT * FROM `manager__shots` WHERE `match_id` = '" $pagePost "' && `type` = 'Goal' && `team_id` = '" $match['home_team'] . "' && `min` <= '" $min "'"));

$away_score mysql_num_rows(mysql_query("SELECT * FROM `manager__shots` WHERE `match_id` = '" $pagePost "' && `type` = 'Goal' && `team_id` = '" $match['away_team'] . "' && `min` <= '" $min "'"));
//$information["score"] = "<strong style=\'font-size: 120%;\'>" . $home_score . " - " . $away_score . "</strong>";

$information['minute'] = date("s"time());


//Convert PHP Array To Javascript Array
        
function get_javascript_array($phpArray$jsArrayName, &$html '') {
                
$html .= $jsArrayName " = new Array(); \r\n ";
                foreach (
$phpArray as $key => $value) {
                        
$outKey = (is_int($key)) ? '[' $key ']' "['" $key "']";

                        if (
is_array($value)) {
                                
get_javascript_array($value$jsArrayName $outKey$html);
                                continue;
                        }
                        
$html .= $jsArrayName $outKey " = ";
                        if (
is_string($value)) {
                                
$html .= "'" $value "'; \r\n ";
                        } else if (
$value === false) {
                                
$html .= "false; \r\n";
                        } else if (
$value === NULL) {
                                
$html .= "null; \r\n";
                        } else if (
$value === true) {
                                
$html .= "true; \r\n";
                        } else {
                                
$html .= $value "; \r\n";
                        }
                }
               
                return 
$html;
        }
//Return The Match Information
    
?>
    <script>
    <?php echo get_javascript_array($information"information"); ?>
    $("#time").html(information['minute']);
    </script>
And The Output Which Doesn't update the time div!

Code:
<script>
    information = new Array(); 
 information['minute'] = '29'; 
     $("#time").html(information['minute']);
    </script>
__________________
SoldierExteme.com - Free MMORPG - sign-up today!
Backthebulls.com - Free online games (mad_willsy's)
Msnextra.co.uk - Msn Items
evans123 is offline
Reply With Quote
View Public Profile
 
Old 11-03-2009, 02:54 PM Re: Load Javascript Array Created By Php And Execute!
wayfarer07's Avatar
NYE-KEE

Posts: 3,155
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
That's not what is being outputted to the browser, it is just an extra puzzle to solve with all that PHP in there. You said the PHP output part is ok. Either a link to the actual page or a copy-paste of the important part of the "view source" is what is needed.
__________________
Wayfarer | jQuery Tooltip Plugin | Mapbox: the jQuery Map
Freelance Jobs Available
If Google is the Coca-Cola of Web search, Bing is RC Cola
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 11-03-2009, 03:01 PM Re: Load Javascript Array Created By Php And Execute!
evans123's Avatar
Ultra Talker

Posts: 350
Trades: 0
http://www.championshipfl.com/

then click on match report in the middle!

When it first loads it is ok and will get the data but i want to refresh it after every minute to get new content but it just doesn't rexecute the javascript outputted.
__________________
SoldierExteme.com - Free MMORPG - sign-up today!
Backthebulls.com - Free online games (mad_willsy's)
Msnextra.co.uk - Msn Items
evans123 is offline
Reply With Quote
View Public Profile
 
Old 11-03-2009, 04:13 PM Re: Load Javascript Array Created By Php And Execute!
evans123's Avatar
Ultra Talker

Posts: 350
Trades: 0
ive found the solution! it returns the array so i used eval() and now i can call upon the new array values!
__________________
SoldierExteme.com - Free MMORPG - sign-up today!
Backthebulls.com - Free online games (mad_willsy's)
Msnextra.co.uk - Msn Items
evans123 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Load Javascript Array Created By Php And Execute!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.13138 seconds with 13 queries