使用.load()加载php结果

时间:2014-02-09 02:49:26

标签: javascript php jquery html

我正在尝试使用.load()在html页面中加载php页面的结果。我想将结果加载到我已包含在html页面中的id为id="div3_example_result"的div元素中...我希望在按下其中一个日历日期时显示结果,因为我正在构建日历。

我已经建立了这个功能:

<script type="text/javascript">
    window.onload = function(){         
        g_globalObject = new JsDatePick({
            useMode:1,
            isStripped:true,
            target:"div3_example"                       

        g_globalObject.setOnSelectedDelegate(function(){
            var obj = g_globalObject.getSelectedDay();
            alert("a date was just selected and the date is : " + obj.day + "/" + obj.month + "/" + obj.year);
            $('#div3_example_result').load('insert.php');               
        });         
    };          
</script>

这是html部分

<body>      
    <br />        
    <div id="div3_example" style="margin-left: 500px; margin-top: 100px; border:dashed 1px red; width:205px; height:230px;">            
    </div>            
    <div id="div3_example_result" style="height:20px; line-height:20px; margin:10px 0 0 0; border:dashed 1px #666;">
    </div>            
</body>

但它不起作用。当我点击一个日期时,只显示警告消息,但div仍然是空的。没有上传结果......你能帮帮我吗?提前谢谢......

php文件:

<html>
<body>

<?php
$con = mysql_connect('127.0.0.1','root','');
if (!$con)
  {
  die('Lidhja me databazen nuk mund te kryhet' .mysql_error(). ' </body></html>');
  }
if(!mysql_select_db("Axhenda",$con))
die('Nuk mund te hapet databaza Axhenda'.mysql_error(). '</body></html>');




$result = mysql_query("SELECT * FROM Perdoruesi");

$row = mysql_fetch_row($result);

echo $row[0]; // 42
echo $row[1]; // the email value
  ?>
</body>
</html>

0 个答案:

没有答案