Welcome Guest, Not a member yet? Register   Sign In
Codeigniter with Ajax
#1

[eluser]Joshi[/eluser]
Hi,

I am very new to ci and Ajax. I have a requirement where i have to dynamically display data in the texbox in onChange event of a drop down.I have tried the code and the data is not passed from the php to the javascript. I have posted the code for your reference.
Code:
sample.php

// My Ajax Function
function getXMLHTTP() { //fuction to return the xml http object

    var xmlhttp=false;    

                try{

             xmlhttp=new XMLHttpRequest();

        }

        catch(e){        

                try{            

                xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");

                 }

            catch(e){

                try{

                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

                }

                catch(e1){

                    xmlhttp=false;

                }

            }

        }

            

        return xmlhttp;

    }

    

    function getBankDetails(strURL) {        

        

        var req = getXMLHTTP();

        

        if (req) {

            

            req.onreadystatechange = function() {

                if (req.readyState == 4) {

                    // only if "OK"

                    if (req.status == 200) {
                                                                                              document.getElementById('bankNameForACH')[removed]=req.responseText;                                

                                                          

                    } else {

                        alert("There was a problem while using XMLHTTP:\n" + req.statusText);

                    }

                }                

            }            
            alert(strURL);

            req.open("GET", strURL, true);

            req.send(null);

        }

                

    }

<table id="ACH" width="100%"  border="0" cellspacing="5" cellpadding="0">
<tr>
    <td  width="120" align="right" class="tahoma12blk">Account No :<span id='require'>*</span></td>
        <select name="accountNoForACH" id="accountNoForACH">
          &lt;?php if($bnkDetails)
            {
            foreach($bnkDetails as $in){?&gt;
                  <option value="&lt;?php echo decrypt($in->accountNo) ?&gt;">&lt;?php echo decrypt($in->accountNo) ?&gt;</option>
                 &lt;?}    
            }?&gt;
          </select>
      </td>
</tr>
<tr>
    <td  width="120" align="right" class="tahoma12blk">Bank Name :<span id='require'>*</span></td>
    <td>&lt;input type="textbox" id="bankNameForACH" name="bankNameForACH" class="input"/&gt;&lt;/td>
</tr>
<tr>
    <td  width="120" align="right" class="tahoma12blk">Routing No : <span id='require'>*</span></td>
    <td>&lt;input type='textbox' name='routingNoForACH' id="routingNoForACH" class="input"/&gt;&lt;/td>
</tr>
</table>

// The function in itemDesc.php
function getDetails($accID){
$decryptAccount = encrypt($accID);
$bankDetails = $this->accounts->getBankAccount($decryptAccount);
$data = array();
$data['bankNameForACH'] = $bankDetails->bankName;
$data['routingNoForACH'] = $bankDetails->routingNo;
$this->load->view('member/sample', $data);

}

I donot know the reason why i dont get the value filled in bankNameForACH and routingNoForACH fields.
I am using document.getElementById('bankNameForACH')[removed]=req.responseText; to print the value.Is this the correct way or should i add or replace this with anything else?Please let me know what am i doing wrong in my code? Looking forward to hear from you at the earliest.


Thanks,
Joshi


Messages In This Thread
Codeigniter with Ajax - by El Forum - 05-28-2010, 03:11 AM
Codeigniter with Ajax - by El Forum - 05-30-2010, 12:38 PM
Codeigniter with Ajax - by El Forum - 05-30-2010, 11:39 PM
Codeigniter with Ajax - by El Forum - 05-31-2010, 05:20 AM
Codeigniter with Ajax - by El Forum - 05-31-2010, 05:38 AM
Codeigniter with Ajax - by El Forum - 05-31-2010, 05:40 AM
Codeigniter with Ajax - by El Forum - 05-31-2010, 05:42 AM
Codeigniter with Ajax - by El Forum - 05-31-2010, 05:42 AM
Codeigniter with Ajax - by El Forum - 05-31-2010, 05:46 AM
Codeigniter with Ajax - by El Forum - 05-31-2010, 05:48 AM
Codeigniter with Ajax - by El Forum - 05-31-2010, 05:52 AM
Codeigniter with Ajax - by El Forum - 05-31-2010, 06:00 AM
Codeigniter with Ajax - by El Forum - 05-31-2010, 06:38 AM
Codeigniter with Ajax - by El Forum - 05-31-2010, 06:42 AM
Codeigniter with Ajax - by El Forum - 05-31-2010, 06:46 AM
Codeigniter with Ajax - by El Forum - 06-01-2010, 03:18 AM
Codeigniter with Ajax - by El Forum - 06-02-2010, 01:05 AM
Codeigniter with Ajax - by El Forum - 06-02-2010, 07:20 AM
Codeigniter with Ajax - by El Forum - 06-02-2010, 07:54 AM
Codeigniter with Ajax - by El Forum - 06-02-2010, 10:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB