• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Warning: headers already sent by ...(for AJAX library)

#1
[eluser]Unknown[/eluser]
hi

im trying to use the projax and tinyAjax library , i also configured them as the are asked in CI wiki but in both case im gating the following warning ( i know why its happened usually "register_globals" , i have tried to fix it by making it off/on but its not working.)

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at D:\wamp\www\PD\system\application\controllers\ajax.php:40)

Filename: errors/error_404.php

Line Number: 1

my controller and view file are as bellow:

Controller:
Code:
<?php
class Ajax extends Controller {
    
    function Ajax()
    {
        parent::Controller();
        $this->load->library('tinyajax');
    }    
        
          
    function multiply()
    {    
        $this->tinyajax->showLoading();
        $this->tinyajax->exportFunction("ajax_multiply", array("first_id", "second_id"), "#third_id", $this);
        
        $this->tinyajax->process();
        $this->load->view('ajax_multiply');
        
    function ajax_multiplyb($x, $y)
    {
      $res = $x * $y;
      $res_text = "Multiplying $x and $y results in $res";
    
      $tab = new TinyAjaxBehavior();
      $tab->add(TabSetValue::getBehavior("third_id", $res));
      $tab->add(TabInnerHtml::getBehavior("result_div", $res_text));
      return $tab->getString();
   }

    function multiplyb()
    {    
        $this->tinyajax->showLoading();
        $this->tinyajax->exportFunction("ajax_multiplyb", array("first_id", "second_id"), null, $this);
        
        $this->tinyajax->process();
        $this->load->view('ajax_multiplyb');
    }
    }    
}
?>

View:
Code:
<html>
<head>
<? $this->tinyajax->drawJavaScript(false,true); ?>
</head>
<body>
    Multiply:<br>
    &lt;input type="text" id="first_id" value="2"&gt; *
    &lt;input type="text" id="second_id" value="3"&gt; =
    &lt;input type="text" id="third_id" value=""&gt;
    &lt;input type="button" value=" * " onclick="ajax_multiplyb()"&gt;
    <br/>
    <div id="result_div">&nbsp;</div>
&lt;/body&gt;
&lt;/html&gt;

i think both of the library is not working for one reason.

will anyone tell me how to fix it ?

#2
[eluser]Lick[/eluser]
Do you have a trailing space or new-line at the end of the file?

Make sure ?&gt; are the EXACT last 2 characters in the file.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.