php+ajax問題??

edited 十月 2013 in 進階PHP討論
<?php
$idpage = $_POST["idParse"];

if ($idpage == "page1")
{
echo "require 'pro_detail/introduce.php'";
}
else if ($idpage == "page2")
{
echo "require 'pro_detail/askAns.php'";
}
else if ($idpage == "page3")
{
echo "require 'pro_detail/assess.php'";
}
?>

====================

function postData(dataSource, divID)
{
var url = dataSource;

request.open("POST", url, true);
request.onreadystatechange = function()
{
if (request.readystate == 4)
{
if (request.status == 200)
{
var objDiv = document.getElementById(divID);
var objphp = '<?php ' + request.responseText +' ?>';
objDiv.innerHTML = objphp;

alert(objphp); ==>會秀出 <?php require 'pro_detail/introduce.php' ?>
}
}
}

request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

request.send(url);
}

==========================
$fobj = new hippo_ajax();

$dataSource1 = 'pro_detail/hippo_ajax_exec.php?qry = 1';
$dataSource2 = 'pro_detail/hippo_ajax_exec.php?qry = 2';
$dataSource3 = 'pro_detail/hippo_ajax_exec.php?qry = 3';

$fobj->add_post_link('page1', "One", $dataSource1, 'showDiv1');
$fobj->add_post_link('page2', "Two", $dataSource2, 'showDiv1');
$fobj->add_post_link('page3', "Three", $dataSource3, 'showDiv1');



<div id="showDiv1"></div>


請問一下,為什當我執行程式時,<div id="showDiv1"></div>這部份會沒反應呢!? 可是我明明有秀出 <?php require 'pro_detail/introduce.php' ?>

原始討論: http://twpug.net/x/modules/newbb/viewtopic.php?topic_id=2336

評論

  • edited 十二月 2006
    if ($idpage == "page1")
    {
    echo "require 'pro_detail/introduce.php'";
    }
    else if ($idpage == "page2")
    {
    echo "require 'pro_detail/askAns.php'";
    }
    else if ($idpage == "page3")
    {
    echo "require 'pro_detail/assess.php'";
    }
    

    也許該改成
    if ($idpage == "page1")
    {
    require 'pro_detail/introduce.php';
    }
    else if ($idpage == "page2")
    {
    ...
    }
    
Sign In or Register to comment.