Welcome Guest, Not a member yet? Register   Sign In
Ajax Framework (CJAX) for Codeigniter 2.x+

[eluser]fran-quero[/eluser]
Hello. Give me a hand with this, please.

I'm trying to use $this->input->post in my ajax controller (application/response/controller), but I always get undefined.

Code:
$ajax->alert($form_fields['name']); //print value successfully
$ajax->alert($this->input->post('a[name]')); //print undefined
$ajax->alert($this->input->post($form_fields['name'])); //print undefined

Can't I use input->post in the ajax controller?

[eluser]Ajaxboy[/eluser]
are you submitting a form with cjax?, if so you should be able to get the values in the $_POST variable or $this->input->post, are you monitoring the ajax requests? if so make sure it's using post.


[eluser]fran-quero[/eluser]
That is what I'm doing:

1) /application/controllers/customers.php

Code:
public function new_customer()
{
     $this->load->helper('form');
    
      $this->data['nombre'] = array(
                                    'name' => 'a[name]',
                                    'id'   => 'name',
                                    'type' => 'text',
                            );
                            $this->data['lastname'] = array(
                                    'name' => 'a[lastname]',
                                    'id'   => 'lastname',
                                    'type' => 'text',
                            );

  $this->load->file(FCPATH.'ajaxfw.php');
  $ajax = ajax();
  $ajax->sendButton = $ajax->form(base_url().'ajax/newcustomer/validateNewCustomer');
  load_view('v_newCustomer', $this->data);

2) /views/v_newCustomer.php
(script tag bad spelled to avoid it being removed)
Code:
<scrip defer='defer' id='cjax_lib' type='text/javascript' src='&lt;?php echo base_url();?&gt;/cjax/core/js/cjax-5.5.min.js'></scrip>

&lt;?php echo form_open("");?&gt;

<p>
                name:
                &lt;?php echo form_input($name);?&gt;
                </p>
                    <p>
                      Last name:
                      &lt;?php echo form_input($lastname);?&gt;
                </p>

<p>&lt;?php echo form_submit('submit', 'New customer','id="sendButton"');?&gt;</p>
      
&lt;?php echo form_close();?&gt;

3) /response/newcustomer/validateNewCustomer.php
Code:
$ajax = ajax();
$ajax->alert($form_fields['name']); //print value successfully
$ajax->alert($this->input->post('a[name]')); //print undefined
$ajax->alert($this->input->post($form_fields['name'])); //print undefined

[eluser]salvomil[/eluser]
Hi Ajaxboy,

and sorry if I repeat the question but I need to do a synchro call using the framework. How can I do it without using pure ajax or Jquery but using only Cjax?

Thank you.

[eluser]fran-quero[/eluser]
Is it possible to bind elements generated dinamically, like jQuery .live() or .on() methods?

I have created an cAjax exec call to an element, that works when the element is in the main view, but doesn't when it's loaded by other cAjax call.

Code:
$ajax->Exec('zip', $ajax->call(base_url().'ajax/newcustomer/locations/|zip|','location'), 'blur');

[eluser]Ajaxboy[/eluser]
As long the element exist you should be able to attach any event. Otherwise you might need to wait for some sort of trigger until the element is created.

[eluser]Ajaxboy[/eluser]
By the way, are you using firebug? or chrome ajax debugger? One of these is essential to be able to debug raw requests which give you more direct information while debugging and fixing stuff

[eluser]Needle[/eluser]
Am I missing something simple here?

I've installed AJAXFW CI 5.4, on Codeigniter version 2.1.4. When I go to run the initial test following the instructions on this page, I get a blank page with no message or error. The network inspector shows that ajax.php?test/test is being fetched successfully.

I've tried this setup on both my local Codeigniter install as well as on a live remote server, both times with the same result. Any help getting this up and running would be greatly appreciated!

[eluser]Ajaxboy[/eluser]
Make sure you meet the minimum requirements:

https://github.com/ajaxboy/cjax

Ps, the latest is Cjax 5.5

[eluser]Needle[/eluser]
Hey, thanks for the speedy reply!

I've upgraded to 5.5, but still no luck with the initial test. Just an empty page. I'm running locally on MAMP using a virtual host, so the URL looks like: dev.myproject:8888/ajax.php?test/test

MAMP is running PHP 5.3.6

I'm using MOD Rewrite to remove the index.php segment but I haven't implemented the ajax rewrite rule that came with the project folder.

My directory structure looks like this:

application/
- response/
-sample.php
-test.php
- controllers/
- AjaxController.php
- views/
test.php
test2.php
ajax.php
ajaxfw.php
cjax/
examples/
index.php
system/




Theme © iAndrew 2016 - Forum software by © MyBB