Jump to content
php.lv forumi

jquery .load()


ziedinjsh

Recommended Posts

Sveiki.

Man te tāda interesanta lieta.

 

Es ar jQuery .load() funkciju

// ielādē komentārus
jQuery(function($) {
jQuery('#show_comments').html('<center><img src="img/loading.gif"/></center>');
jQuery('#show_comments').load('show_comments.php');
});

 

ielādēju komentārus

 

<?php
include('process/dbase.php');
$id = isset($_GET['id']) ? $_GET['id'] : '';
$comment = mysql_query("select * from comments where aid='$id' order by id desc") or die(mysql_error());
while($data = mysql_fetch_array($comment)){
echo '
<div class="commentWarp">
 <div class="cNick">@ '.$data['author'].'</div>
 <div class="cComment">'.$data['comment'].'</div>
 <div class="cBottom">'.$data['date'].'</div>
</div>
';
}
?>

 

Lieta tāda, ka jQuery savu funkciju izpild (pārbaudiju ar alert();), bet komentārus neparāda. Includojot php failu iekš div komentārus parāda. Kāds iepesls varētu būt ka jQuery it kā ielādē failu, bet nerāda faila saturu?

Link to comment
Share on other sites

neiebraucu ar $.ajax.

Mēģināju šādi:

 

Html

<div id="show_comments" class="30"></div>

 

jQuery

jQuery(function($) {
var id = $('#show_comments').attr('class');
jQuery('#show_comments').html('<center><img src="img/loading.gif"/></center>');
jQuery('#show_comments').load('show_comments.php?id=id');
});

 

clasi nolasa (pārbaudija ar alert();) bet failā viņš neatver. Ieliekot iekš php ?id=id vietā ?id=$id atvēra

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...