CodeIgniter Forums

Full Version: help with xajax examples for codeigniter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I'm trying implementing the following example in codeigniter
however I'm having problems.
Attached is my non-working code.

Here is the complete demo site:


Class Searching Extends Controller {
function Searching()    {
    //ini_set('display_errors', 'On');

function getCities($sSearch)  {
  $aCities = array(
  $sOut = "";
  $nCount = 0;
  foreach($aCities as $sCity)  {
    $sPattern = "/^(".strtolower($sSearch).")/";
    if(preg_match($sPattern, strtolower($sCity)))  {
        $sOut .= "<li></li>";
        $sLastHit = $sCity;
  if($nCount > 31)  {
    $sOut = "";
    $objResponse = new xajaxResponse();
  if(strlen($sOut) > 0)  {
    $sOut = "<ul>".$sOut."</ul>";
    $objResponse->addScript("document.getElementById('citybox').style.display = \"block\"");
  else  {
    $objResponse->addScript("document.getElementById('citybox').style.display = \"none\"");
if($nCount == 1)  {
    $objResponse->addScript("document.getElementById('citybox').style.display = \"none\"");
    $objResponse->addScript("document.getElementById('search').value = \"".$sLastHit."\"");
    $objResponse->addAssign("citybox", "innerHTML", $sOut);  
    return $objResponse->getXML();

function index() {
    $template['head'] = $this->xajax->printJavascript();
    $template['xajax_js'] = $this->xajax->getJavascript(base_url() . "demo");
    $template['content'] = "&lt;input autocomplete=\"off\" type=\"text\" class=\"textbox\" name=\"search\" value=\"\" id=\"search\" onkeyup=\"xajax_getCities(document.getElementById('search').value);\"/&gt;<br />";
    $template['citybox_content'] = '<div id="citybox">&nbsp;</div>';
    $this->load->view('searching_view', $template);





&lt;title&gt;Searching 0.1 test&lt;/title&gt;



El Forum

what are the errors?

El Forum

I'm going to compare "my" code and this one:

El Forum

Sorry, but

whats with people not using the "code" tags....?

El Forum

hey dont be too hard on him..i also forgot those tags once in a while before.Wink
and rvent is right,with that much code,you should put it between code tags...its kinda confusing.

El Forum

sorry guys ... just fixed the post.

El Forum

[eluser]Đỗ Thanh Tùng[/eluser]
How about xajax library. I thinks that library cant be load