Reputation: 45
1.Jquery Script with Ajax
$('#location').change(function(){
var l = $('#location :selected').val();
$.ajax({
type:'POST',
url : 'function/get_location.php',
dataType:'html',
data : { loc : l},
success: function(data){
$('#advertise_record').html(data);
}
});
});
i want to see the html code the response from server displayed in a blog div called #advertise_record in my web page . but when right clicked view source code i didn't see that html code inside that blog but the result of it show here.
2.html code
<div id="advertise_record"></div>
i need the result that response from server display here. it's show the result but when i right click view source code i didn't see that code.
3. get_location.php
<?php
include_once (dirname(__FILE__). '/dbconfig.php');
define('ADVERTISE_DIRECTORY','../advertise/');
if(isset($_POST['loc'])) $loc = mysql_real_escape_string($_POST['loc']);
switch($loc){
case 0 : $sql = 'SELECT * FROM tblads';break;
case 1 : $sql = 'SELECT * FROM tblads WHERE loc_id="'.$loc.'"'; break;
case 2 : $sql = 'SELECT * FROM tblads WHERE loc_id="'.$loc.'"'; break;
case 3 : $sql = 'SELECT * FROM tblads WHERE loc_id="'.$loc.'"'; break;
default:"";
}
?>
<table border="1" cellpadding="5" cellspacing="5" width="850px;">
<tbody>
<tr>
<td><input type="file" name="filename" id="filename" class="text"/></td>
<td><label class="title">Name :</label><input type="text" name="ads_name" id="ads_name" class="text" style="width:150px;"></td>
<td><label class="title">URL :</label><input type="text" name="url" id="url" class="text" style="width:150px;"/></td>
<td><input type="button" name="update" id="update" class="button button_update"/></td>
</tr>
<?php
$output = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($output)){
?>
<tr>
<td colspan="3" align="center">
<div style="width: 700px;height: auto;overflow-x: scroll;">
<img src='<?php echo ADVERTISE_DIRECTORY.$row['image_name']?>' alt='<?php echo $row['ads_name'];?>' />
</div>
</td>
<td align="center"><a href='#tab-advertise?edit=<?php echo $row['ads_id']?>' >Edit</a></td>
</tr>
<?php
}
?>
</tbody>
</table>
so what's wrong with my code . really thank for you time to answer.
Upvotes: 0
Views: 245
Reputation: 97717
You're not going to see anything in the source that wasn't there initially. If you want to see the html that is returned by your ajax calls check the network/net tab in your browsers development tools. Also you're setting the content type for an image which is incorrect since your output is an html table.
Upvotes: 2