Magento displays same page inside the visible page when trying to send/receive data from another php -
i'm trying make new functionality on custom back-end module i've created few weeks ago. new functionality consists in making query in order list in 'select-option' data specific customer. then, when select 1 of these options, i've made script catch option, send get
method .php, , then, php makes data selected , makes echo whatever.
the code following (data.phtml
):
<script language="javascript" type="text/javascript"> function showpresu(str){ if (str=="") { document.getelementbyid("txthint").innerhtml=""; alert('nothing here'); return; } if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); alert('makes request'); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); alert('new object'); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { document.getelementbyid("txthint").innerhtml=xmlhttp.responsetext; } } xmlhttp.open("get","receiveselection.php?q="+str,true); xmlhttp.send(); } </script>
as can notice i've written alerts in order make sure code enters inside script.
the select/option following(data.phtml
):
echo '<select name="presus" onchange="showpresu(this.value)">'; for($n=1;$n<=$h; $n++){ echo "<option value='$status_id[$n]'>$status_id[$n]"; } echo "</select>";
$status_id[$x]: it's array contains data i've introduced @ beginning.
and div final data has displayed (data.phtml
):
<div id="txthint"> <b>result info listed here.</b> </div>
and finally, php has interact info send via method get
(receiveselection.php
, in same folder data.phtml
. notice php changed code, mean, change following code make query, making tests it's ok):
<?php $q=$_get["q"]; echo $q; ?>
the issue is, when try show 'receiveselecton.php' in div created so, instead of watching result of 'receiveselection.php' appears same magento page in moment before (data.phtml
), mean, appears same page twice, 1 'normal' , other inside div
.
does know how call receiveselection.php
instead of creating data.phtml
?
edit: if put code outside magento works, inside not. problem maybe incoherence magento don't know. or if knows better way it, please tell me.
i tried code in sustem working fine.. problem figured out request sending not able reach file receiveselection.php
solution problem can create controller action receiveselection.php lets receiveselectionaction change code this
xmlhttp.open("get","your_module/your_controller/receiveselection.php?q="+str,true);
Comments
Post a Comment