Topic: Xajax & HMVC & Codeigniter

Hi, I have a problem. Ajax is looking for a handler function in the same directory from which it caused. How to make the search function in a different directory?

For example a call is in the directory user, and need to look in the directory admin

My code is:

onclick="xajax_create_user(xajax.getFormValues('reg_form'));" - call in the "user" directory

function "create_user" in the "admin" directory !

Ajax is looking for a function in the user directory instead of the admin.



sorry for my english !!!

Re: Xajax & HMVC & Codeigniter

Hello,

you can handle the request target with an specified url.
Have a look in "tests" folder at basic plugin test

There is an function $reqShowOutput = $xajax->register(XAJAX_FUNCTION, "showOutput");

adding at least an array into the register

$reqShowOutput = $xajax->register(XAJAX_FUNCTION, "showOutput",array(
'URI'=>'"/relative_to_admin/admin_login_form.php"'));

you can also adding the requesting method from post to get or get to post like

$reqShowOutput = $xajax->register(XAJAX_FUNCTION, "showOutput",array(
'URI'=>'"/relative_to_admin/admin_login_form.php"'
'method' =>'POST'
));

Re: Xajax & HMVC & Codeigniter

Thank you. but I do not quite understand how to use it with
$ this-> xajax-> register (XAJAX_FUNCTION, array ('call_create_user', & $ this, 'call_create_user'));

Re: Xajax & HMVC & Codeigniter

open the following example from xajax

File: registerObjectTest.php

Script to test callable objects.

Title: Call methods of registered objects.

have a look for from line 111 and modify the expression as the following lines

$requestClassMethod = $xajax->register(XAJAX_FUNCTION, array(
    "testForm2",
    "myObjectTest",
    "testClassMethod"), array('method' => '"post"', 'URI' =>
        "'urlparameter_reciver.php'"));

by comparing the original with my example, you see the last array as last parameter
:
array('method' => '"post"', 'URI' =>
        "'urlparameter_reciver.php'")

so i have "re routed" the url to request for


create an new file called  urlparameter_reciver.php at the same directory
<?php
/** the reciver class **/
require_once ("../xajax_core/xajax.inc.php");
$xajax = new xajax();

class myObjectTest
{


    function testClassMethod($formData)
    {
        $objResponse = new xajaxResponse();
        $objResponse->alert("This is a class method. You have send an request from an other Scriptfile");
        $objResponse->alert("formData: " . print_r($formData, true));
        $objResponse->assign("submittedDiv", "innerHTML", nl2br(print_r($formData, true)));


        return $objResponse;
    }
}
$requestClassMethod = $xajax->register(XAJAX_FUNCTION, array(
    "testForm2",
    "myObjectTest",
    "testClassMethod"));

$xajax->processRequest();

?>


open your browser and compare the alert messages ;-)

an short example at http://xajax.base.jftp.de/tests/urlparameter.php