如何将响应文本显示为html并同时发送到php页面

如何将响应文本显示为html并同时发送到php页面,php,javascript,ajax,open-flash-chart,Php,Javascript,Ajax,Open Flash Chart,calculate.php <form method="post" name="frm_deptcal" id="frm_deptcal" action="javascript:add(document.getElementById('frm_deptcal'));" > <span style="font-weight:bold;">Enter your total unsecured* debt </span> <input type="te

calculate.php

<form method="post" name="frm_deptcal" id="frm_deptcal"     action="javascript:add(document.getElementById('frm_deptcal'));" >
<span style="font-weight:bold;">Enter your total unsecured* debt </span>
<input type="text" name="txt_principal" id="txt_principal" / >
<input type="submit" name="button" value="Calculate" style="background: none repeat scroll 0% 0% rgb(51, 136, 180); color: white; border: 5px solid rgb(120, 176, 205); cursor: pointer;">
</form>
在value.php中,我进行了计算:

$principal=$_POST['txt_principal'];    
$x=0.3;
$consumer_mon_pay=60;
$mp_consumer_ans=($principal * $x)/$consumer_mon_pay;
$mp_consumer=round($mp_consumer_ans,3)   ;         
echo $mp_repay."[BRK]".$mp_conloan."[BRK]".$mp_credit."[BRK]".$mp_consumer; 
在ajax_cal.js中,我得到了html格式的响应,并显示在文本框中

function show()
{
    if (XMLHttpRequestObject.readyState == 4)
    {
        if (XMLHttpRequestObject.status == 200)
        {
            data = XMLHttpRequestObject.responseText.split("[BRK]");
            document.getElementById('txt_mp_repay').innerHTML = data[0];
            document.getElementById('txt_mp_conloan').innerHTML = data[1];   
            document.getElementById('txt_mp_credit').innerHTML = data[2];  
            document.getElementById('txt_mp_consumer').innerHTML = data[3];  

        }
    }

}

现在我的问题是我必须绘制一个动态图,其x轴应该是(txt\u mp\u偿还,txt\u mp\u贷款,txt\u mp\u信贷,txt\u mp\u消费者)值和y轴将是txt_mp_return值。条形图编码是使用chart-data.php中的open flash chart完成的,通过它我创建了一个静态图。问题是如何将响应发送到chart-data.php并在calculate.php页面上显示整个内容。帮帮我…谢谢

我有点不清楚您想做什么,但没有什么能阻止您同时发送两个ajax请求。像

var str1= "txt_principal=" + document.getElementById("txt_principal").value;
XMLHttpRequestObject.onreadystatechange = show;
XMLHttpRequestObject.open('POST', 'value.php', true);
XMLHttpRequestObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
XMLHttpRequestObject.send(str1);    
XMLHttpRequestObject.open('POST', 'chart.php', true);
XMLHttpRequestObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
XMLHttpRequestObject.send(str1);    
var str1= "txt_principal=" + document.getElementById("txt_principal").value;
XMLHttpRequestObject.onreadystatechange = show;
XMLHttpRequestObject.open('POST', 'value.php', true);
XMLHttpRequestObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
XMLHttpRequestObject.send(str1);    
XMLHttpRequestObject.open('POST', 'chart.php', true);
XMLHttpRequestObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
XMLHttpRequestObject.send(str1);