本文介绍了如何将响应文本显示为html并同时发送到php页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 calculate.php < form 方法 = post name = frm_deptcal id = frm_deptcal 操作 = javascript:add (document.getElementById('frm_deptcal')); > < span style = font-weight:bold; > 输入您的总无担保*债务< / span > < ; 输入 type = text 名称 = txt_principal id = txt_principal / > < input type = 提交 名称 = 按钮 value = 计算 样式 = 背景:无重复滚动0%0%rgb(51,136,180);白颜色;边界:5px solid rgb(120,176,205); cursor:pointer; > < / form > ajax_cal.js我有add()其中创建XMLHttpRequestObject并发送字符串代码: < pre > 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); 在value.php中我做了计算: $ principal = $ _ POST [''txt_principal'']; $ x = 0.3; $ consumer_mon_pay = 60; $ mp_consumer_ans =($ pri ncipal * $ 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并在文本框中显示 函数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_mp_repay,txt_mp_conloan,txt_mp_credit,txt_mp_consumer)值,y轴为txt_mp_repay值。条形图编码使用chart-data.php中的open-flash图表完成通过它我创建了一个静态graph.Problem是如何将响应发送到chart-data.php并显示计算.php页面上的全部内容。帮助我...谢谢解决方案 主要= _POST [ '' txt_principal '']; X = 0.3; 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>in ajax_cal.js i have add() in which XMLHttpRequestObject is created and string is sendcode : <pre> 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);In value.php i have done calculation: $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; and in ajax_cal.js i have got the response as html and showed in textbox 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]; } } }now my problem is I have to plot a dynamic graph whose x -axis should be the (txt_mp_repay,txt_mp_conloan,txt_mp_credit,txt_mp_consumer ) values and y -axis will be txt_mp_repay value .the bar graph coding is done using open-flash chart in chart-data.php through which I have created a static graph.Problem is how to send the response to chart-data.php and show the whole thing on calculate .php page.Help me...Thanks 解决方案 principal=_POST[''txt_principal''];x=0.3; 这篇关于如何将响应文本显示为html并同时发送到php页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-17 19:02