Re: How do I get Cake 3.1 to reply to an AJAX request without requiring a layout .ctp file?

2015-10-15 Thread heavyKevy
Okay, problem solved.
The _ext is not needed, removed it.
added the line:
$this->RequestHandler->renderAs($this, 'json');

Now renders as a JsonView and the _Serialize is automatically detected and 
no template file required.

Regards,
--Kevin

On Wednesday, October 14, 2015 at 2:02:24 PM UTC+7, heavyKevy wrote:
>
> I have gone through the documentation, which is a bit too vague, and tried 
> many things, but I still am getting an error that the template file is 
> missing.
>
> I had this working sending back a json response in 3.0 using ext='json', 
> yet after updating to 3.1 it is broken.  
>
> I checked the migration guide and tried changing ext  to _ext, setting up 
> the Routes with:
> Router::extensions(['json']);
>
> in the controller method I am using the _serialize key which is supposed 
> to render without the template:
> $this->set('_serialize', ['salesPeople']);
>
> The JsonView class does not appear to be loading and I don't see in the 
> documentation where I am supposed to set it.
> The documentation says ' you can automatically leverage the new view 
> classes' By enabling RequestHandlerComponent in your application, and 
> enabling support for the json and or xml extensions, but I have enabled 
> it in the Initialize method of the controller and enabled the 'json' 
> extension as mentioned earlier and it is still not working.
>
> Here is the method in question:
> public function getSalesPeopleSelectList() {
> $this->request->accepts('json'); // No direct access via browser 
> URL
> $dealerId = $this->request->params['pass'][0];
> $this->RequestHandler->renderAs($this, 'ajax');
> //$this->viewClass = 'Json';
> $this->loadModel('SalesPeople');
> $salesPeople = 
> $this->Purchases->SalesPeople->find('list')->where(['is_active'=>'1','user_id'=>$dealerId]);
>   
> //for salespeople options for autocomplete
> $this->set(compact('salesPeople'));
> $this->set('_serialize', ['salesPeople']);
> }
>
>
> When I enable the _ext = json I get the following error:
>
> 2015-10-14 06:57:36 Error: 
> [Cake\Controller\Exception\MissingActionException] Action 
> PurchasesController::getSalesPeopleSelectList.json() could not be found, or 
> is not accessible.
> Exception Attributes: array (
>   'controller' => 'PurchasesController',
>   'action' => 'getSalesPeopleSelectList.json',
>   'prefix' => '',
>   'plugin' => NULL,
> )
> Request URL: /Subaru/purchases/get-sales-people-select-list.json/47
> Stack Trace:
> #0 
> C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(114):
>  
> Cake\Controller\Controller->invokeAction()
> #1 
> C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(87):
>  
> Cake\Routing\Dispatcher->_invoke(Object(App\Controller\PurchasesController))
> #2 C:\WebServer\webdocs\Subaru\index.php(42): 
> Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request), 
> Object(Cake\Network\Response))
> #3 {main}
>
> What have I missed?
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: How do I get Cake 3.1 to reply to an AJAX request without requiring a layout .ctp file?

2015-10-14 Thread heavyKevy
I discovered a bug in the Route.php file.
the reg expression used for finding extensions only works if no parameters 
are passed in the URL.
I have temporarily modified my Routes.php file to find the extension 
anywhere in the string and used str_replace to remove the .json from the 
url and I no longer get the action missing error.
I still get the template missing error though.

On Wednesday, October 14, 2015 at 2:02:24 PM UTC+7, heavyKevy wrote:
>
> I have gone through the documentation, which is a bit too vague, and tried 
> many things, but I still am getting an error that the template file is 
> missing.
>
> I had this working sending back a json response in 3.0 using ext='json', 
> yet after updating to 3.1 it is broken.  
>
> I checked the migration guide and tried changing ext  to _ext, setting up 
> the Routes with:
> Router::extensions(['json']);
>
> in the controller method I am using the _serialize key which is supposed 
> to render without the template:
> $this->set('_serialize', ['salesPeople']);
>
> The JsonView class does not appear to be loading and I don't see in the 
> documentation where I am supposed to set it.
> The documentation says ' you can automatically leverage the new view 
> classes' By enabling RequestHandlerComponent in your application, and 
> enabling support for the json and or xml extensions, but I have enabled 
> it in the Initialize method of the controller and enabled the 'json' 
> extension as mentioned earlier and it is still not working.
>
> Here is the method in question:
> public function getSalesPeopleSelectList() {
> $this->request->accepts('json'); // No direct access via browser 
> URL
> $dealerId = $this->request->params['pass'][0];
> $this->RequestHandler->renderAs($this, 'ajax');
> //$this->viewClass = 'Json';
> $this->loadModel('SalesPeople');
> $salesPeople = 
> $this->Purchases->SalesPeople->find('list')->where(['is_active'=>'1','user_id'=>$dealerId]);
>   
> //for salespeople options for autocomplete
> $this->set(compact('salesPeople'));
> $this->set('_serialize', ['salesPeople']);
> }
>
>
> When I enable the _ext = json I get the following error:
>
> 2015-10-14 06:57:36 Error: 
> [Cake\Controller\Exception\MissingActionException] Action 
> PurchasesController::getSalesPeopleSelectList.json() could not be found, or 
> is not accessible.
> Exception Attributes: array (
>   'controller' => 'PurchasesController',
>   'action' => 'getSalesPeopleSelectList.json',
>   'prefix' => '',
>   'plugin' => NULL,
> )
> Request URL: /Subaru/purchases/get-sales-people-select-list.json/47
> Stack Trace:
> #0 
> C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(114):
>  
> Cake\Controller\Controller->invokeAction()
> #1 
> C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(87):
>  
> Cake\Routing\Dispatcher->_invoke(Object(App\Controller\PurchasesController))
> #2 C:\WebServer\webdocs\Subaru\index.php(42): 
> Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request), 
> Object(Cake\Network\Response))
> #3 {main}
>
> What have I missed?
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: How do I get Cake 3.1 to reply to an AJAX request without requiring a layout .ctp file?

2015-10-14 Thread Kevin Arnett
code that generated the URL:
$url = $this->Url->build(['controller' => 'Purchases', 'action' =>
'get_sales_people_select_list','_ext'=>'json']);
$url = $url . '/47';

The generated URL:
/purchases/get-sales-people-select-list.json/47

Is this not correct?

On Wed, Oct 14, 2015 at 4:40 PM, Anthony GRASSIOT 
wrote:

> Did you correctly specify the data type json in your ajax call ?
> Le 14 oct. 2015 09:02, "heavyKevy"  a écrit :
>
>> I have gone through the documentation, which is a bit too vague, and
>> tried many things, but I still am getting an error that the template file
>> is missing.
>>
>> I had this working sending back a json response in 3.0 using ext='json',
>> yet after updating to 3.1 it is broken.
>>
>> I checked the migration guide and tried changing ext  to _ext, setting up
>> the Routes with:
>> Router::extensions(['json']);
>>
>> in the controller method I am using the _serialize key which is supposed
>> to render without the template:
>> $this->set('_serialize', ['salesPeople']);
>>
>> The JsonView class does not appear to be loading and I don't see in the
>> documentation where I am supposed to set it.
>> The documentation says ' you can automatically leverage the new view
>> classes' By enabling RequestHandlerComponent in your application, and
>> enabling support for the json and or xml extensions, but I have enabled
>> it in the Initialize method of the controller and enabled the 'json'
>> extension as mentioned earlier and it is still not working.
>>
>> Here is the method in question:
>> public function getSalesPeopleSelectList() {
>> $this->request->accepts('json'); // No direct access via browser
>> URL
>> $dealerId = $this->request->params['pass'][0];
>> $this->RequestHandler->renderAs($this, 'ajax');
>> //$this->viewClass = 'Json';
>> $this->loadModel('SalesPeople');
>> $salesPeople =
>> $this->Purchases->SalesPeople->find('list')->where(['is_active'=>'1','user_id'=>$dealerId]);
>> //for salespeople options for autocomplete
>> $this->set(compact('salesPeople'));
>> $this->set('_serialize', ['salesPeople']);
>> }
>>
>>
>> When I enable the _ext = json I get the following error:
>>
>> 2015-10-14 06:57:36 Error:
>> [Cake\Controller\Exception\MissingActionException] Action
>> PurchasesController::getSalesPeopleSelectList.json() could not be found, or
>> is not accessible.
>> Exception Attributes: array (
>>   'controller' => 'PurchasesController',
>>   'action' => 'getSalesPeopleSelectList.json',
>>   'prefix' => '',
>>   'plugin' => NULL,
>> )
>> Request URL: /Subaru/purchases/get-sales-people-select-list.json/47
>> Stack Trace:
>> #0
>> C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(114):
>> Cake\Controller\Controller->invokeAction()
>> #1
>> C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(87):
>> Cake\Routing\Dispatcher->_invoke(Object(App\Controller\PurchasesController))
>> #2 C:\WebServer\webdocs\Subaru\index.php(42):
>> Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request),
>> Object(Cake\Network\Response))
>> #3 {main}
>>
>> What have I missed?
>>
>> --
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "CakePHP" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to cake-php+unsubscr...@googlegroups.com.
>> To post to this group, send email to cake-php@googlegroups.com.
>> Visit this group at http://groups.google.com/group/cake-php.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/31AlwVDJmv8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: How do I get Cake 3.1 to reply to an AJAX request without requiring a layout .ctp file?

2015-10-14 Thread Anthony GRASSIOT
Did you correctly specify the data type json in your ajax call ?
Le 14 oct. 2015 09:02, "heavyKevy"  a écrit :

> I have gone through the documentation, which is a bit too vague, and tried
> many things, but I still am getting an error that the template file is
> missing.
>
> I had this working sending back a json response in 3.0 using ext='json',
> yet after updating to 3.1 it is broken.
>
> I checked the migration guide and tried changing ext  to _ext, setting up
> the Routes with:
> Router::extensions(['json']);
>
> in the controller method I am using the _serialize key which is supposed
> to render without the template:
> $this->set('_serialize', ['salesPeople']);
>
> The JsonView class does not appear to be loading and I don't see in the
> documentation where I am supposed to set it.
> The documentation says ' you can automatically leverage the new view
> classes' By enabling RequestHandlerComponent in your application, and
> enabling support for the json and or xml extensions, but I have enabled
> it in the Initialize method of the controller and enabled the 'json'
> extension as mentioned earlier and it is still not working.
>
> Here is the method in question:
> public function getSalesPeopleSelectList() {
> $this->request->accepts('json'); // No direct access via browser
> URL
> $dealerId = $this->request->params['pass'][0];
> $this->RequestHandler->renderAs($this, 'ajax');
> //$this->viewClass = 'Json';
> $this->loadModel('SalesPeople');
> $salesPeople =
> $this->Purchases->SalesPeople->find('list')->where(['is_active'=>'1','user_id'=>$dealerId]);
> //for salespeople options for autocomplete
> $this->set(compact('salesPeople'));
> $this->set('_serialize', ['salesPeople']);
> }
>
>
> When I enable the _ext = json I get the following error:
>
> 2015-10-14 06:57:36 Error:
> [Cake\Controller\Exception\MissingActionException] Action
> PurchasesController::getSalesPeopleSelectList.json() could not be found, or
> is not accessible.
> Exception Attributes: array (
>   'controller' => 'PurchasesController',
>   'action' => 'getSalesPeopleSelectList.json',
>   'prefix' => '',
>   'plugin' => NULL,
> )
> Request URL: /Subaru/purchases/get-sales-people-select-list.json/47
> Stack Trace:
> #0
> C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(114):
> Cake\Controller\Controller->invokeAction()
> #1
> C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(87):
> Cake\Routing\Dispatcher->_invoke(Object(App\Controller\PurchasesController))
> #2 C:\WebServer\webdocs\Subaru\index.php(42):
> Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request),
> Object(Cake\Network\Response))
> #3 {main}
>
> What have I missed?
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


How do I get Cake 3.1 to reply to an AJAX request without requiring a layout .ctp file?

2015-10-14 Thread heavyKevy
I have gone through the documentation, which is a bit too vague, and tried 
many things, but I still am getting an error that the template file is 
missing.

I had this working sending back a json response in 3.0 using ext='json', 
yet after updating to 3.1 it is broken.  

I checked the migration guide and tried changing ext  to _ext, setting up 
the Routes with:
Router::extensions(['json']);

in the controller method I am using the _serialize key which is supposed to 
render without the template:
$this->set('_serialize', ['salesPeople']);

The JsonView class does not appear to be loading and I don't see in the 
documentation where I am supposed to set it.
The documentation says ' you can automatically leverage the new view 
classes' By enabling RequestHandlerComponent in your application, and 
enabling support for the json and or xml extensions, but I have enabled it 
in the Initialize method of the controller and enabled the 'json' extension 
as mentioned earlier and it is still not working.

Here is the method in question:
public function getSalesPeopleSelectList() {
$this->request->accepts('json'); // No direct access via browser URL
$dealerId = $this->request->params['pass'][0];
$this->RequestHandler->renderAs($this, 'ajax');
//$this->viewClass = 'Json';
$this->loadModel('SalesPeople');
$salesPeople = 
$this->Purchases->SalesPeople->find('list')->where(['is_active'=>'1','user_id'=>$dealerId]);
  
//for salespeople options for autocomplete
$this->set(compact('salesPeople'));
$this->set('_serialize', ['salesPeople']);
}


When I enable the _ext = json I get the following error:

2015-10-14 06:57:36 Error: 
[Cake\Controller\Exception\MissingActionException] Action 
PurchasesController::getSalesPeopleSelectList.json() could not be found, or 
is not accessible.
Exception Attributes: array (
  'controller' => 'PurchasesController',
  'action' => 'getSalesPeopleSelectList.json',
  'prefix' => '',
  'plugin' => NULL,
)
Request URL: /Subaru/purchases/get-sales-people-select-list.json/47
Stack Trace:
#0 
C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(114):
 
Cake\Controller\Controller->invokeAction()
#1 
C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(87): 
Cake\Routing\Dispatcher->_invoke(Object(App\Controller\PurchasesController))
#2 C:\WebServer\webdocs\Subaru\index.php(42): 
Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request), 
Object(Cake\Network\Response))
#3 {main}

What have I missed?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Authentication and multiple ajax request

2015-01-17 Thread euromark
Well, what you are doing there is pretty wrong in the first place.
Calling login($data) directly logs in whatever you send it (see the docs 
for details), rendering a form login process invalid and insecure.
You should, just as with any other non-ajax request, properly use the Auth 
adapters to log that person in, thus preventing
it from being called twice.
Because if your wrong login() call does work the first time (as it always 
does with whatever data you feed it), the second one
then fails because that person is already logged in. This can and should be 
caught before hand and the login process then aborted
with the message "already logged in".

mark



Am Samstag, 17. Januar 2015 07:12:45 UTC+1 schrieb Ryan de Haast:
>
> Hi All
>
> I recently discovered that cake authentication class does not like 
> multiple ajax requests.
>
> While recently testing my app, I found it would return a 403 error the 
> moment I do multiple ajax requests on a logged in user.
>
> I managed to narrow it down to the following code:
>
>
> $auth = $this->Session->read("Auth");
>>
>> $this->Auth->login($auth);
>>
>> $this->Session->write("Auth",$auth);
>>
>
> The Auth session variable would contain all the login details based on the 
> user.
>
> The above code is in the beforeFilter function within my AppController. 
> Upon debugging the first ajax attempt would send the $auth variable through 
> to the $this->Auth->login($auth); however every other ajax event would fail 
> result in a 403 error being returned.
> After much debugging I managed to discover the above. I checked on every 
> test run whether the session variable returned any data and whether the 
> session data was passed through to isAuthorized function in the same 
> controller.
>
> The session data was never empty, but would only enter the isAuthroized 
> function on the first ajax event, but not on the consecutive ajax events.
>
> Would anybody know a solution to this problem?
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Authentication and multiple ajax request

2015-01-17 Thread Ryan de Haast
Hi All

I recently discovered that cake authentication class does not like multiple 
ajax requests.

While recently testing my app, I found it would return a 403 error the 
moment I do multiple ajax requests on a logged in user.

I managed to narrow it down to the following code:


$auth = $this->Session->read("Auth");
>
> $this->Auth->login($auth);
>
> $this->Session->write("Auth",$auth);
>

The Auth session variable would contain all the login details based on the 
user.

The above code is in the beforeFilter function within my AppController. 
Upon debugging the first ajax attempt would send the $auth variable through 
to the $this->Auth->login($auth); however every other ajax event would fail 
result in a 403 error being returned.
After much debugging I managed to discover the above. I checked on every 
test run whether the session variable returned any data and whether the 
session data was passed through to isAuthorized function in the same 
controller.

The session data was never empty, but would only enter the isAuthroized 
function on the first ajax event, but not on the consecutive ajax events.

Would anybody know a solution to this problem?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Ajax request

2013-09-25 Thread Gaurav Matta
For better solution do not refresh the button but only the search result.
On 25-Sep-2013 6:47 PM,  wrote:

> Hello,
> I have a problem with a search field on my site and I hope you can help
> me. I got a table called "Clients" with some information like firstname,
> lastname, adress etc. and all MVC files. For testing I use the Client index
> function. In my view file I have a input field where I want to search for
> clients. when I type at least 4 letter the search function should
> automaticaly display the client names in a div container under the search
> field (like the google instant search). Basically it is working, but after
> first search I got a second input in my clients div and after some searches
> it will break. I think my solution is also not the right way to do this.
> Here is my code:
>
> *Controller:*
> public function index($searchterm=NULL) {
>
> if ( $this->RequestHandler->isAjax() ) {
>
> $clients=$this->Client->find('list', array(
> 'conditions'=>array('LOWER(Client.lname) LIKE
> \''.$searchterm.'%\''),
> 'limit'=>500
> ));
>
> $this->set('clients', $clients);
> }
>
> }
> *
> View:*
> 
>
> $(function() {
> $( "#element", this ).keyup(function( event ) {
> if( $(this).val().length >= 4 ) {
> $.ajax({
> url: '/clients/index/' + escape( $(this).val() ),
> cache: false,
> type: 'GET',
> dataType: 'HTML',
> success: function (clients) {
> $('#clients').html(clients);
> }
> });
> }
> });
> });
> 
>
> Form->input('element', array('id'=>'element'));?>
>
> 
>  foreach ($clients as $client) {
> echo '';
> echo $client;
> }
> ?>
> 
>
> I hope you can help me to improve this a little...
>
>  --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Ajax request

2013-09-25 Thread Gaurav Matta
You will need to rewrite the autocomplete code on page you are requesting
on the fly for search.
If I am correct your search is also Ajax based...
On 25-Sep-2013 6:47 PM,  wrote:

> Hello,
> I have a problem with a search field on my site and I hope you can help
> me. I got a table called "Clients" with some information like firstname,
> lastname, adress etc. and all MVC files. For testing I use the Client index
> function. In my view file I have a input field where I want to search for
> clients. when I type at least 4 letter the search function should
> automaticaly display the client names in a div container under the search
> field (like the google instant search). Basically it is working, but after
> first search I got a second input in my clients div and after some searches
> it will break. I think my solution is also not the right way to do this.
> Here is my code:
>
> *Controller:*
> public function index($searchterm=NULL) {
>
> if ( $this->RequestHandler->isAjax() ) {
>
> $clients=$this->Client->find('list', array(
> 'conditions'=>array('LOWER(Client.lname) LIKE
> \''.$searchterm.'%\''),
> 'limit'=>500
> ));
>
> $this->set('clients', $clients);
> }
>
> }
> *
> View:*
> 
>
> $(function() {
> $( "#element", this ).keyup(function( event ) {
> if( $(this).val().length >= 4 ) {
> $.ajax({
> url: '/clients/index/' + escape( $(this).val() ),
> cache: false,
> type: 'GET',
> dataType: 'HTML',
> success: function (clients) {
> $('#clients').html(clients);
> }
> });
> }
> });
> });
> 
>
> Form->input('element', array('id'=>'element'));?>
>
> 
>  foreach ($clients as $client) {
> echo '';
> echo $client;
> }
> ?>
> 
>
> I hope you can help me to improve this a little...
>
>  --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Ajax Request

2013-09-25 Thread webgaertner
Hello,
I have a problem with a search field on my site and I hope you can help me. 
I got a table called "Clients" with some information like firstname, 
lastname, adress etc. and all MVC files. For testing I use the Client index 
function. In my index view file I have a input field where I want to search 
for clients. when I type at least 4 letter the search function should 
automaticaly display the client names in a div container under the search 
field (like the google instant search). Basically it is working, but after 
first search I got a second input in my clients div and after some searches 
it will break. I think my solution is also not the right way to do this. 
Here is my code:

*Controller:*
public function index($searchterm=NULL) {

if ( $this->RequestHandler->isAjax() ) {

$clients=$this->Client->find('list', array(
'conditions'=>array('LOWER(Client.lname) LIKE 
\''.$searchterm.'%\''),
'limit'=>500
));

$this->set('clients', $clients);
}

}
*
View:*


$(function() {
$( "#element", this ).keyup(function( event ) {
if( $(this).val().length >= 4 ) {
$.ajax({
url: '/clients/index/' + escape( $(this).val() ),
cache: false,
type: 'GET',
dataType: 'HTML',
success: function (clients) {
$('#clients').html(clients);
}
});
}
});
});


Form->input('element', array('id'=>'element'));?>


';
echo $client;
}
?>


I hope you can help me to improve this a little...

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Ajax request

2013-09-25 Thread webgaertner
Hello,
I have a problem with a search field on my site and I hope you can help me. 
I got a table called "Clients" with some information like firstname, 
lastname, adress etc. and all MVC files. For testing I use the Client index 
function. In my view file I have a input field where I want to search for 
clients. when I type at least 4 letter the search function should 
automaticaly display the client names in a div container under the search 
field (like the google instant search). Basically it is working, but after 
first search I got a second input in my clients div and after some searches 
it will break. I think my solution is also not the right way to do this. 
Here is my code:

*Controller:*
public function index($searchterm=NULL) {

if ( $this->RequestHandler->isAjax() ) {

$clients=$this->Client->find('list', array(
'conditions'=>array('LOWER(Client.lname) LIKE 
\''.$searchterm.'%\''),
'limit'=>500
));

$this->set('clients', $clients);
}

}
*
View:*


$(function() {
$( "#element", this ).keyup(function( event ) {
if( $(this).val().length >= 4 ) {
$.ajax({
url: '/clients/index/' + escape( $(this).val() ),
cache: false,
type: 'GET',
dataType: 'HTML',
success: function (clients) {
$('#clients').html(clients);
}
});
}
});
});


Form->input('element', array('id'=>'element'));?>


';
echo $client;
}
?>


I hope you can help me to improve this a little...

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Ajax Request resulting in exponential requests.

2013-05-01 Thread Anthony France
So, I've got the following bit of code:

start('search'); ?>
Js->get('#ItemIndexForm')->serializeForm(array('isForm' => 
true, 'inline' => true));
$this->Js->get('#ItemIndexForm 
#ItemName')->event('keyup',$this->Js->request(array('action' => 'index'), 
array('update' => '#content', 'data' => $data, 'async' => true, 'method' => 
'POST')));
$this->Js->get('#ItemIndexForm')->event('submit', 
$this->Js->request(array('action' => 'index'), array('update' => 
'#content','data' => $data,'async' => true, 'method' => 'POST')));
?>
Form->create('Item'); ?>
Form->input('Item.name'); ?>
Form->submit(); ?>
Form->end(); ?>
end(); ?>

I'm calling writeBuffer at the end of the view for ajax pagination. 

That creates a search form that creates a search block that is fetched into 
my layout, I did it this way so that when we update #content the search 
form doesn't get reloaded and lose focus.  (not sure if that was the best 
way to do it or not).

It works, however the first key press results in one request, the second in 
two, the third in four request, and so on.  Same for submitting with the 
submit button, each submission results in an exponential number of requests.

I'm pretty sure I know why it's doing it but not sure why it would actually 
work that way.  My theory is that when it receives the data back its 
binding again to the search form thats coming from the reply even though 
that part is getting stripped out.  It's getting stripped out because its 
not inside #content.  However that doesn't really seem to be the case.  

How can I resolve this issue?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Is there any way to display error when working on ajax request?

2013-05-01 Thread Anthony
use debug and tail the debug.log file.

On Wednesday, February 9, 2011 12:43:42 PM UTC-6, cake-learner wrote:
>
> I set up one class to handle all ajax request called ajax_controll. 
> The thing is everytime I develop a function and there is some kind of 
> syntactic errors it returns empty. Usually take a couple of hours to 
> develop 
> one simple query because of this. Is it anyway to spit out the php 
> error on 
> browser( maybe there is firebug plugin? )

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




CakePHP and Ajax request

2013-03-20 Thread Piotr Chabros
Hi

I am currently using ajax in multiple controllers in my application. I 
implemented the ajax functionality using the jQuery supported version.

$.ajax({
url:'getCountries',
type: "POST",
dataType: "html",
data:"data=" + result,
success: function(data){
//magic...
}
}
});

As you can see from the code above the url of this request is 
'getCountries'. This means that if the request is made from 
'http://localhost/appname/controllername/methodname' the request url will 
be  'http://localhost/appname/controllername/getCountries'. However if the 
url is different, say 
 'http://localhost/appname/controllername/methodname/7' (like in the edit 
view) or 
( 'http://localhost/appname/controllername/methodname/order:Model.field' 
(like in the pagination) then the request url will dramaticly change to 
 'http://localhost/appname/controllername/methodname/getCountries' in the 
first case and even worse in the second. How can I avoid that?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




RE: Render Element with AJAX Request / Response

2012-10-19 Thread Advantage+
Thanks,

 

That does work!

$view_output = $this->render('add')->body());

 

But I also found another way.

 

$html_view = new View($this, false);

$view_output = $html_view->render('add');

 

Is there a difference in either in terms of processing the request? Is 1
more efficient over the other?

 

Thanks,

Dave

 

From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of majna
Sent: Friday, October 19, 2012 8:46 AM
To: cake-php@googlegroups.com
Subject: Re: Render Element with AJAX Request / Response

 

Hi,

Controller::render() returns CakeResponse object, so try

'html' => $this->render()->body()


On Friday, October 19, 2012 2:56:44 AM UTC+2, advantage+ wrote:

My original function to return a JSON array no longer works with v2.1.3

 

This worked in 1.3: loaded a form into a modal window

 

Controller code snip:

if ( empty( $this->data ) ) {

$this->data = $record; //debug shows the $record so there is
data / debug is at 0 now

$response = array(

'status' => true,

'title' => $record['Education']['program'],

'html' => $this->render());

}



$this->_ajaxReturn( $response ); //simply encodes and returns the $response
echo json_encode($response);

 

But the html data is no longer being rendered into the JSON response. The
fancybox loads but no HTML.

 

The js for the ADD link in the view calls this js:

$(".add").live('click', function (){

$.fancybox.showActivity();

$.ajax({

type: "GET",

url: $(this).attr("href"),

cache: false,

resetForm: true,

dataType: 'json',


success: function(r) {

$.fancybox({

 
'autoDimensions' :   false,

 
'opacity' : 1,

 
'width' : 740,

 
'margin' : 10,

 
'padding' : 10,

 
'content' : r.html});







}

});

return false;   

});

 

 

The JSON response looks like this:

{"status":true,"title":"Auto Generated For Development","html_view":{}}

 

Any ideas?

 

Thanks,

Dave

 

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
--- 
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Render Element with AJAX Request / Response

2012-10-19 Thread majna
Hi,

Controller::render() returns CakeResponse object, so try

'html' => $this->render()->body()


On Friday, October 19, 2012 2:56:44 AM UTC+2, advantage+ wrote:
>
> My original function to return a JSON array no longer works with v2.1.3
>
>  
>
> This worked in 1.3: loaded a form into a modal window
>
>  
>
> Controller code snip:
>
> if ( empty( $this->data ) ) {
>
> $this->data = $record; //debug shows the $record so there 
> is data / debug is at 0 now
>
> $response = array(
>
> 'status' => true,
>
> 'title' => $record['Education']['program'],
>
> 'html' => $this->render());
>
> }
>
> 
>
> $this->_ajaxReturn( $response ); //simply encodes and returns the 
> $response echo json_encode($response);
>
>  
>
> But the html data is no longer being rendered into the JSON response. The 
> fancybox loads but no HTML.
>
>  
>
> The js for the ADD link in the view calls this js:
>
> $(".add").live('click', function (){
>
> $.fancybox.showActivity();
>
> $.ajax({
>
> type: "GET",
>
> url: $(this).attr("href"),
>
> cache: false,
>
> resetForm: true,
>
> dataType: 
> 'json',   
>
> success: function(r) {
>
> 
> $.fancybox({
>
>   
>   
> 'autoDimensions' :   false,
>
>   
>   
> 'opacity' : 1,
>
>   
>   
> 'width' : 740,
>
>   
>   
> 'margin' : 10,
>
>   
>   
> 'padding' : 10,
>
>   
>   
> 'content' : r.html});
>
> 
>
> 
>
> 
>
> }
>
> });
>
> return false;   
>
> });
>
>  
>
>  
>
> The JSON response looks like this:
>
> {"status":true,"title":"Auto Generated For Development","html_view":{}}
>
>  
>
> Any ideas?
>
>  
>
> Thanks,
>
> Dave
>
>  
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Render Element with AJAX Request / Response

2012-10-18 Thread Vanja Dizdarević
 

> $this->_ajaxReturn( $response ); //simply encodes and returns the 
> $response echo json_encode($response);
>
Returns to what? 

Your best bet is to use a JSON view: 
http://book.cakephp.org/2.0/en/views/json-and-xml-views.html

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Render Element with AJAX Request / Response

2012-10-18 Thread Advantage+
My original function to return a JSON array no longer works with v2.1.3

 

This worked in 1.3: loaded a form into a modal window

 

Controller code snip:

if ( empty( $this->data ) ) {

$this->data = $record; //debug shows the $record so there is
data / debug is at 0 now

$response = array(

'status' => true,

'title' => $record['Education']['program'],

'html' => $this->render());

}



$this->_ajaxReturn( $response ); //simply encodes and returns the $response
echo json_encode($response);

 

But the html data is no longer being rendered into the JSON response. The
fancybox loads but no HTML.

 

The js for the ADD link in the view calls this js:

$(".add").live('click', function (){

$.fancybox.showActivity();

$.ajax({

type: "GET",

url: $(this).attr("href"),

cache: false,

resetForm: true,

dataType: 'json',


success: function(r) {

$.fancybox({

 
'autoDimensions' :   false,

 
'opacity' : 1,

 
'width' : 740,

 
'margin' : 10,

 
'padding' : 10,

 
'content' : r.html});







}

});

return false;   

});

 

 

The JSON response looks like this:

{"status":true,"title":"Auto Generated For Development","html_view":{}}

 

Any ideas?

 

Thanks,

Dave

 

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Chosen doesn't work after ajax request

2012-07-19 Thread mebibyte
Hey 

I'm using chosen for a dynamic multiselect, see 
link<http://harvesthq.github.com/chosen/>
. 
I works perfectly but when I put it in a view which a call with ajax the 
javascript doesn't work anymore.
So how can I run a javascript after a ajax request.

the view with the request:

Form->create('SearchForQuestions');
?>


Form->input('mainTopic',array('label' => 'Vak:','empty' 
=> true));  ?>
 Html->image('loader.gif'); ?>
 


observeField('SearchForQuestionsMainTopic',
 array(
'url' => array( 'action' => 'get_children' ),
'frequency' => 0.2,
'indicator' => 'loader',
'update' => 'childTopics'
 )
); 
 echo $this->Form->end();
?>

the view which is called with ajax:
Html->css(array('chosen'),'stylesheet', array('inline' => 
false ) ); ?>
 Chosen
   

  
Multiple Select with Groups

  
 
Dallas Cowboys
New York Giants
Philadelphia Eagles
Washington Redskins

  
Chicago Bears
Detroit Lions
Green Bay Packers
Minnesota Vikings
 

  

 
 https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js"</a>; 
type="text/javascript">
 
  
  
  document.observe('dom:loaded', function(evt) {
var select, selects, _i, _len, _results;
if (Prototype.Browser.IE && (Prototype.BrowserFeatures['Version'] === 6 
|| Prototype.BrowserFeatures['Version'] === 7)) {
  return;
}
selects = $$(".chzn-select");
_results = [];
for (_i = 0, _len = selects.length; _i < _len; _i++) {
  select = selects[_i];
  _results.push(new Chosen(select));
}
deselects = $$(".chzn-select-deselect");
for (_i = 0, _len = deselects.length; _i < _len; _i++) {
  select = deselects[_i];
  _results.push(new Chosen(select,{allow_single_deselect:true}));
}
return _results;
  });

  

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Problem with empty Ajax-Request-Response

2011-12-29 Thread Gerrit
Hello everybody,

I've a problem with my JQuery Mobile Application. When I open my Web
Root I become redirected by Auth Component to my Login-Action. When I
try to request the same webroot via Ajax the response is empty. Jquery
mobile therefore writes Undifined as result in my browser window. Has
anybody an anser for this problem? I use Jquery Mobile 1.0 and CakePHP
2.0. It's hosted on workutil.glweb.de

Thanks for your help!

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: debug level on ajax request

2011-08-27 Thread p r
further reading 
http://cakephp.lighthouseapp.com/projects/42648/tickets/1941-changing-debug-level-on-runtime

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: debug level on ajax request

2011-08-26 Thread p r
thanks this is a good point. i think it is a problem in generally, not
only on ajax requests...

if (isset($config['debug']) || isset($config['log'])) {
$reporting = 0;
if ($_this->debug) {

this lines from configure config['debug'] is set but 0 because new
Configure::write from app controller beforeFilter function. but i
don't see a setter for $_this->debug




On 25 Aug., 18:49, stas kim 
wrote:
> oops. it's not on boot strap only. my bad.
>
> On Thu, Aug 25, 2011 at 12:47 PM, stas kim
>
>
>
>
>
>
>
>  wrote:
> > it's probably because of this line
> >https://github.com/cakephp/cakephp/blob/master/cake/libs/configure.ph...
> > which is executed on bootstrap. meaning even if you change debug level
> > later in your controller it will only effect Debugger class behavior
>
> > cheers
>
> > On Wed, Aug 24, 2011 at 11:21 AM, Ben McClure  wrote:
> >> Fixing warnings and notices is not the answer to his question--With debug
> >> mode off, he should not be getting such messages displayed. At worse, he
> >> should be seeing formatted Cake errors or simply a blank page if something
> >> is wrong.
> >> Perhaps the warnings/notices/errors are being thrown before you
> >> call Configure::write('debug', 0); ? If so, try calling it earlier in your
> >> code.
> >> Or perhaps something else is changing the value of debug back to 1 or
> >> greater?
> >> You could echo something from inside that if() block to make sure it is
> >> actually hitting the code which sets the debug value to 0.
> >> Beyond that, I don't know what else to have you try :)
> >> Ben
>
> >> --
> >> Our newest site for the community: CakePHP Video Tutorials
> >>http://tv.cakephp.org
> >> Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> >> others with their CakePHP related questions.
>
> >> To unsubscribe from this group, send email to
> >> cake-php+unsubscr...@googlegroups.com For more options, visit this group at
> >>http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: debug level on ajax request

2011-08-25 Thread stas kim
oops. it's not on boot strap only. my bad.

On Thu, Aug 25, 2011 at 12:47 PM, stas kim
 wrote:
> it's probably because of this line
> https://github.com/cakephp/cakephp/blob/master/cake/libs/configure.php#L119
> which is executed on bootstrap. meaning even if you change debug level
> later in your controller it will only effect Debugger class behavior
>
>
> cheers
>
> On Wed, Aug 24, 2011 at 11:21 AM, Ben McClure  wrote:
>> Fixing warnings and notices is not the answer to his question--With debug
>> mode off, he should not be getting such messages displayed. At worse, he
>> should be seeing formatted Cake errors or simply a blank page if something
>> is wrong.
>> Perhaps the warnings/notices/errors are being thrown before you
>> call Configure::write('debug', 0); ? If so, try calling it earlier in your
>> code.
>> Or perhaps something else is changing the value of debug back to 1 or
>> greater?
>> You could echo something from inside that if() block to make sure it is
>> actually hitting the code which sets the debug value to 0.
>> Beyond that, I don't know what else to have you try :)
>> Ben
>>
>> --
>> Our newest site for the community: CakePHP Video Tutorials
>> http://tv.cakephp.org
>> Check out the new CakePHP Questions site http://ask.cakephp.org and help
>> others with their CakePHP related questions.
>>
>>
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.com For more options, visit this group at
>> http://groups.google.com/group/cake-php
>>
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: debug level on ajax request

2011-08-25 Thread stas kim
it's probably because of this line
https://github.com/cakephp/cakephp/blob/master/cake/libs/configure.php#L119
which is executed on bootstrap. meaning even if you change debug level
later in your controller it will only effect Debugger class behavior


cheers

On Wed, Aug 24, 2011 at 11:21 AM, Ben McClure  wrote:
> Fixing warnings and notices is not the answer to his question--With debug
> mode off, he should not be getting such messages displayed. At worse, he
> should be seeing formatted Cake errors or simply a blank page if something
> is wrong.
> Perhaps the warnings/notices/errors are being thrown before you
> call Configure::write('debug', 0); ? If so, try calling it earlier in your
> code.
> Or perhaps something else is changing the value of debug back to 1 or
> greater?
> You could echo something from inside that if() block to make sure it is
> actually hitting the code which sets the debug value to 0.
> Beyond that, I don't know what else to have you try :)
> Ben
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at
> http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: debug level on ajax request

2011-08-24 Thread Ben McClure
Fixing warnings and notices is not the answer to his question--With debug 
mode off, he should not be getting such messages displayed. At worse, he 
should be seeing formatted Cake errors or simply a blank page if something 
is wrong.

Perhaps the warnings/notices/errors are being thrown before you call 
Configure::write('debug', 
0); ? If so, try calling it earlier in your code.

Or perhaps something else is changing the value of debug back to 1 or 
greater?

You could echo something from inside that if() block to make sure it is 
actually hitting the code which sets the debug value to 0.

Beyond that, I don't know what else to have you try :)

Ben

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: debug level on ajax request

2011-08-24 Thread p r
yes you're right. but the debug mode is for developing purposes and my
question belongs to control the debug mode in app controller.


On 22 Aug., 10:28, "Dr. Loboto"  wrote:
> The best way is to fix that warnings and notices. Good app never
> throws this kind of shit.
>
> On 18 авг, 20:18, p r  wrote:
>
>
>
>
>
>
>
> > yes the Requesthandler is in use and the debug level is set correctly
> > to 0 but errors and notices doesn't care.
> > It seems the backtrace is added before the debug level is set in
> > AppController? When i set the debug level in core.php it works as i
> > desired.
>
> > On 18 Aug., 15:06, mi...@brightstorm.co.uk wrote:
>
> > > > Hello,
>
> > > > could anybody explain this behavior? i set in my app controller
>
> > > > if($this->RequestHandler->isAjax()) {
> > > >                    $this->layout = 'ajax';
> > > >                    $this->autoRender = false;
> > > >                    Configure::write('debug', 0);
> > > > }
>
> > > > but notices and errors are even so sent. only when i set in core.php
> > > > the debug level to 0, no notices etc. occures.
>
> > > if requesthandler is working, you can do
>
> > >  if($this->params['isAjax']==1) {
> > >                         $this->layout = 'ajax';
> > >                         $this->autoRender = false;
> > >                         Configure::write('debug', 0);
> > >  }
>
> > > > greetings
>
> > > > --
> > > > Our newest site for the community: CakePHP Video Tutorials
> > > >http://tv.cakephp.org
> > > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> > > > others with their CakePHP related questions.
>
> > > > To unsubscribe from this group, send email to
> > > > cake-php+unsubscr...@googlegroups.com For more options, visit this group
> > > > athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: debug level on ajax request

2011-08-22 Thread Dr. Loboto
The best way is to fix that warnings and notices. Good app never
throws this kind of shit.

On 18 авг, 20:18, p r  wrote:
> yes the Requesthandler is in use and the debug level is set correctly
> to 0 but errors and notices doesn't care.
> It seems the backtrace is added before the debug level is set in
> AppController? When i set the debug level in core.php it works as i
> desired.
>
> On 18 Aug., 15:06, mi...@brightstorm.co.uk wrote:
>
>
>
>
>
>
>
> > > Hello,
>
> > > could anybody explain this behavior? i set in my app controller
>
> > > if($this->RequestHandler->isAjax()) {
> > >                    $this->layout = 'ajax';
> > >                    $this->autoRender = false;
> > >                    Configure::write('debug', 0);
> > > }
>
> > > but notices and errors are even so sent. only when i set in core.php
> > > the debug level to 0, no notices etc. occures.
>
> > if requesthandler is working, you can do
>
> >  if($this->params['isAjax']==1) {
> >                         $this->layout = 'ajax';
> >                         $this->autoRender = false;
> >                         Configure::write('debug', 0);
> >  }
>
> > > greetings
>
> > > --
> > > Our newest site for the community: CakePHP Video Tutorials
> > >http://tv.cakephp.org
> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> > > others with their CakePHP related questions.
>
> > > To unsubscribe from this group, send email to
> > > cake-php+unsubscr...@googlegroups.com For more options, visit this group
> > > athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: debug level on ajax request

2011-08-18 Thread p r
yes the Requesthandler is in use and the debug level is set correctly
to 0 but errors and notices doesn't care.
It seems the backtrace is added before the debug level is set in
AppController? When i set the debug level in core.php it works as i
desired.



On 18 Aug., 15:06, mi...@brightstorm.co.uk wrote:
> > Hello,
>
> > could anybody explain this behavior? i set in my app controller
>
> > if($this->RequestHandler->isAjax()) {
> >                    $this->layout = 'ajax';
> >                    $this->autoRender = false;
> >                    Configure::write('debug', 0);
> > }
>
> > but notices and errors are even so sent. only when i set in core.php
> > the debug level to 0, no notices etc. occures.
>
> if requesthandler is working, you can do
>
>  if($this->params['isAjax']==1) {
>                         $this->layout = 'ajax';
>                         $this->autoRender = false;
>                         Configure::write('debug', 0);
>  }
>
>
>
>
>
>
>
>
>
> > greetings
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group
> > athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: debug level on ajax request

2011-08-18 Thread mikek
> Hello,
>
> could anybody explain this behavior? i set in my app controller
>
> if($this->RequestHandler->isAjax()) {
>   $this->layout = 'ajax';
>   $this->autoRender = false;
>   Configure::write('debug', 0);
> }
>
> but notices and errors are even so sent. only when i set in core.php
> the debug level to 0, no notices etc. occures.

if requesthandler is working, you can do

 if($this->params['isAjax']==1) {
$this->layout = 'ajax';
$this->autoRender = false;
Configure::write('debug', 0);
 }






>
> greetings
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>
>


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: debug level on ajax request

2011-08-18 Thread mikek
> Hello,
>
> could anybody explain this behavior? i set in my app controller
>
> if($this->RequestHandler->isAjax()) {
>   $this->layout = 'ajax';
>   $this->autoRender = false;
>   Configure::write('debug', 0);
> }
>
> but notices and errors are even so sent. only when i set in core.php
> the debug level to 0, no notices etc. occures.

have you added the RequestHandler component to your controller?


>
> greetings
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>
>


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


debug level on ajax request

2011-08-18 Thread p r
Hello,

could anybody explain this behavior? i set in my app controller

if($this->RequestHandler->isAjax()) {
$this->layout = 'ajax';
$this->autoRender = false;
Configure::write('debug', 0);
}

but notices and errors are even so sent. only when i set in core.php
the debug level to 0, no notices etc. occures.

greetings

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Detect session timeout with on AJAX request with javascript

2011-06-23 Thread Gonçalo
Hi there.

I've been looking for a way to detect on the client side that the ajax
request he performed was not successful because the user session has
expired.
My problem is not related with security level (seen too many people
with this one..).

I've red this blog post:
 - http://deadlytechnology.com/php/ajax-session-expire-bug/
that explains that this was a bug, and also the supposed correction:
 -
http://cakephp.lighthouseapp.com/projects/42648/tickets/658-session-timeout-auth-component-403-status-code-being-dropped-when-request-via-ajax

I've also looked into the code, and it seems that if the user performs
an ajax request without a valid session, all i can get is a 403 server
error on the client side.

Is this actually the only way to check if i should redirect the user
to the login page?

I know i can also override the redirect method to handle this better,
but i think that it makes sense that the framework can handle this.

Thanks is advance for any response

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Ajax request sends 2 times

2011-03-14 Thread Jens Dittrich
Why are you mixing the (deprecated) Ajax-Helper with html code for a
form? Have you tried relying on the helper to produce the code for
your form?

On 14 Mrz., 14:21, heohni 
wrote:
> Hi,
>
> I have this form:
> Ajax->Form('searchMember', 'post', array('update' =>
> 'target', 'url' => array('action' => 'searchMember'))); ?>
> 
> Suchwort:
> 
> 
> 
> 
> Ajax->Form->end(); ?>
>
> And everytime I press the submit button, the request is send 2 times,
> I can see this with firebug in my firefox.
> Is there something wrong in the $this->Ajax->Form part?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Ajax request sends 2 times

2011-03-14 Thread cricket
On Mon, Mar 14, 2011 at 9:21 AM, heohni
 wrote:
> Hi,
>
> I have this form:
> Ajax->Form('searchMember', 'post', array('update' =>
> 'target', 'url' => array('action' => 'searchMember'))); ?>
> 
> Suchwort:
> 
> 
> 
> 
> Ajax->Form->end(); ?>
>
> And everytime I press the submit button, the request is send 2 times,
> I can see this with firebug in my firefox.
> Is there something wrong in the $this->Ajax->Form part?

I don't use the AjaxHelper so can't be sure. Can you show the relevant
HTML and JS that's created?

And are you using JQuery? Which version?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Ajax request sends 2 times

2011-03-14 Thread heohni
Hi,

I have this form:
Ajax->Form('searchMember', 'post', array('update' =>
'target', 'url' => array('action' => 'searchMember'))); ?>

Suchwort:




Ajax->Form->end(); ?>

And everytime I press the submit button, the request is send 2 times,
I can see this with firebug in my firefox.
Is there something wrong in the $this->Ajax->Form part?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Is there any way to display error when working on ajax request?

2011-02-10 Thread Sam Sherlock
I use one of the following

1) Firephp.
http://www.firephp.org

2) What Krissy said

3) sticking vars in an array and using
json_encode(compact('hasThisThingSucceeded', 'isTheFlagFlying'));
so if you project is handling the reponse and looking for content I would
compact a set of vars to the var
that gets returned as content. The you get the output within the page (this
can go wrong, but is sometime helpful)


 - S




On 9 February 2011 18:58, Krissy Masters  wrote:

> I sometimes do a print_r($data); in the view / response code just to see
> whats coming back if im getting noting / errors just so I can "visually"
> see
> something to pin-point whats going wrong, if there is infact data and work
> from there.
>
> Or execute a debug(); exit(); in the function itself right before the save
> or delete so its runs but does not complete the request so I can see if
> everything up to the save / delelte is working and what I have right before
> that.
>
> -Original Message-
> From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On
> Behalf
> Of ibejohn818
> Sent: Wednesday, February 09, 2011 3:17 PM
> To: CakePHP
> Subject: Re: Is there any way to display error when working on ajax
> request?
>
> Since your method of request for the action is ajax, I'm assuming it's
> publicly accessible.
>
> So the best way to dev it is thru the browser then apply your ajax
> formatting to the action one you are completed with it.
>
> www.mysite.com/ajax/my_action
>
> On Feb 9, 10:43 am, cake-learner  wrote:
> > I set up one class to handle all ajax request called ajax_controll.
> > The thing is everytime I develop a function and there is some kind of
> > syntactic errors it returns empty. Usually take a couple of hours to
> > develop
> > one simple query because of this. Is it anyway to spit out the php
> > error on
> > browser( maybe there is firebug plugin? )
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at
> http://groups.google.com/group/cake-php
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


RE: Is there any way to display error when working on ajax request?

2011-02-09 Thread Krissy Masters
I sometimes do a print_r($data); in the view / response code just to see
whats coming back if im getting noting / errors just so I can "visually" see
something to pin-point whats going wrong, if there is infact data and work
from there.

Or execute a debug(); exit(); in the function itself right before the save
or delete so its runs but does not complete the request so I can see if
everything up to the save / delelte is working and what I have right before
that.

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of ibejohn818
Sent: Wednesday, February 09, 2011 3:17 PM
To: CakePHP
Subject: Re: Is there any way to display error when working on ajax request?

Since your method of request for the action is ajax, I'm assuming it's
publicly accessible.

So the best way to dev it is thru the browser then apply your ajax
formatting to the action one you are completed with it.

www.mysite.com/ajax/my_action

On Feb 9, 10:43 am, cake-learner  wrote:
> I set up one class to handle all ajax request called ajax_controll.
> The thing is everytime I develop a function and there is some kind of
> syntactic errors it returns empty. Usually take a couple of hours to
> develop
> one simple query because of this. Is it anyway to spit out the php
> error on
> browser( maybe there is firebug plugin? )

-- 
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help
others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at
http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Is there any way to display error when working on ajax request?

2011-02-09 Thread ibejohn818
Since your method of request for the action is ajax, I'm assuming it's
publicly accessible.

So the best way to dev it is thru the browser then apply your ajax
formatting to the action one you are completed with it.

www.mysite.com/ajax/my_action

On Feb 9, 10:43 am, cake-learner  wrote:
> I set up one class to handle all ajax request called ajax_controll.
> The thing is everytime I develop a function and there is some kind of
> syntactic errors it returns empty. Usually take a couple of hours to
> develop
> one simple query because of this. Is it anyway to spit out the php
> error on
> browser( maybe there is firebug plugin? )

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Is there any way to display error when working on ajax request?

2011-02-09 Thread cake-learner
I set up one class to handle all ajax request called ajax_controll.
The thing is everytime I develop a function and there is some kind of
syntactic errors it returns empty. Usually take a couple of hours to
develop
one simple query because of this. Is it anyway to spit out the php
error on
browser( maybe there is firebug plugin? )

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Odd RequestHandler->isAjax evaluation during ajax request in webkit browsers

2011-01-29 Thread BARTCC
Hi,
yesterday I noticed some odd behavior of my web app while testing it
in Safari:
Here is the line of code in my controller where it all the weirdness
happens:

if (!$this->RequestHandler->isAjax()) {
$this->Session->write('Auth.User.activeRecordId', NO_ID);
$this->Session->write('Auth.User.isajax', 'false'); // for
better readability
}

I'm trying to decide if my variable should be '__noId__' for "this is
the first time I get called so I have no ID yet" or ''this is ajax,
leave this var alone"

Normally this should be turn out to be true (no ajax) only in the very
first request which is a GET. The subsequent requests which are kicked
off automatically, are ajax calls, the first against the same index
action, the second one against the view action of the same controller.
Done ... normally. Looking into Safari one strange behavior came to
light (as opposed to Firefox): Safari sets up sometimes one, sometimes
even two additional requests AFTER the /controller/view request, which
are considered by the server to be GET requests - so my var is written
over;((
I traced this down with $this->log right in the Sessions write method:

Safari:

0011-01-28 03:15:19 Debug: write into session: Config.time =>
1296192919
2011-01-28 03:15:19 Debug: write into session:
Auth.User.activeRecordId => __noid__
2011-01-28 03:15:19 Debug: write into session: Auth.User.isajax =>
false
2011-01-28 03:15:19 Debug: write into session: url.url => /
2011-01-28 03:15:19 Debug: write into session: url.page => 1
2011-01-28 03:15:19 Debug: write into session: Acl.error.check => 1
---
2011-01-28 03:15:26 Debug: write into session: Config.time =>
1296192926
2011-01-28 03:15:26 Debug: write into session: Acl.error.status => 200
2011-01-28 03:15:26 Debug: write into session: Message.flash => Array
2011-01-28 03:15:26 Debug: write into session: Acl.error.check => 1
---
2011-01-28 03:15:27 Debug: write into session: Config.time =>
1296192926
2011-01-28 03:15:27 Debug: write into session: Auth.User.isajax =>
true
2011-01-28 03:15:27 Debug: write into session: url.url => products/
index/all
2011-01-28 03:15:27 Debug: write into session: url.page => 1
2011-01-28 03:15:27 Debug: write into session: Acl.error.check => 1
---
2011-01-28 03:15:27 Debug: write into session: Config.time =>
1296192927
2011-01-28 03:15:27 Debug: write into session:
Auth.User.activeRecordId => 4d390234-9804-4e0a-af50-71dcc0a8010b
2011-01-28 03:15:27 Debug: write into session: Acl.error.check => 1
---
2011-01-28 03:15:28 Debug: write into session: Config.time =>
1296192927
2011-01-28 03:15:28 Debug: write into session:
Auth.User.activeRecordId => __noid__
2011-01-28 03:15:28 Debug: write into session: Auth.User.isajax =>
false
2011-01-28 03:15:28 Debug: write into session: url.url => /
2011-01-28 03:15:28 Debug: write into session: url.page => 1
2011-01-28 03:15:28 Debug: write into session: Acl.error.check => 1
---
---

Firefox:

2011-01-28 03:16:24 Debug: write into session: Config.time =>
1296192984
2011-01-28 03:16:24 Debug: write into session:
Auth.User.activeRecordId => __noid__
2011-01-28 03:16:24 Debug: write into session: Auth.User.isajax =>
false
2011-01-28 03:16:24 Debug: write into session: url.url => /
2011-01-28 03:16:24 Debug: write into session: url.page => 1
2011-01-28 03:16:24 Debug: write into session: Acl.error.check => 1
---
2011-01-28 03:16:27 Debug: write into session: Config.time =>
1296192987
2011-01-28 03:16:27 Debug: write into session: Acl.error.status => 200
2011-01-28 03:16:27 Debug: write into session: Message.flash => Array
2011-01-28 03:16:27 Debug: write into session: Acl.error.check => 1
---
2011-01-28 03:16:29 Debug: write into session: Config.time =>
1296192988
2011-01-28 03:16:29 Debug: write into session: Auth.User.isajax =>
true
2011-01-28 03:16:29 Debug: write into session: url.url => products/
index/all
2011-01-28 03:16:29 Debug: write into session: url.page => 1
2011-01-28 03:16:29 Debug: write into session: Acl.error.check => 1

starting ajax request from php

2010-08-31 Thread Tomfox Wiranata
hi,

usually i do this to implement ajax feeling:

VIEW:
with jquery I call the controller functions and tell cake where (in a
DIV) to write the result

$('#attachments_count').load('countattachments');


CONTROLLER
then all the logic happens in my controller function,
countattachments, and I tell cake to render the ouput:

$this->set('amount_of_attachments', $input);
$this->render('render_attachment_count','ajax');

voila..i see the result in that DIV in AJAX manner.

BUT now I do not have the jquery-part.. I have a value in my
controller and i would like to write that value in a DIV, in ajax
manner, cause i dont want to load the whole site. here is what i do

$amount_of_attachments = 
$this->countattachments();

if ($amount_of_attachments < 5)
{
  > RENDER the value in a DIV
}

is that even possible???

i appreciate your help

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Action, called by an Ajax request, running twice.

2010-05-24 Thread WebbedIT
I had weird problems with ajax calls happening twice (when deleting a
record in a modalbox).  I'm pretty certain it came down to using
FireBug for me which sometimes, but not all the time, reloads the
request to get some extra information.

Paul.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Action, called by an Ajax request, running twice.

2010-05-23 Thread John Andersen
Check that you are returning false to the form itself, when you submit
the form with ajax, as else the form will think that it must also
submit!
Does this apply to your case?
Enjoy,
   John

On May 22, 7:00 pm, Felipe Carballo 
wrote:
> Hello guys! I'm having a problem using jQuery UI and Ajax Helper, with
> Prototype. My form is opened in a dialog box using jQuery UI. When I
> send the form, my action is executed twice. If I remove the library
> jQuery UI, the action is performed correctly (once). Does anyone know
> how I can fix this problem?
>
> Sorry for my bad English.
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with 
> their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Action, called by an Ajax request, running twice.

2010-05-22 Thread Felipe Carballo
Hello guys! I'm having a problem using jQuery UI and Ajax Helper, with
Prototype. My form is opened in a dialog box using jQuery UI. When I
send the form, my action is executed twice. If I remove the library
jQuery UI, the action is performed correctly (once). Does anyone know
how I can fix this problem?

Sorry for my bad English.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Adding postdata to a ajax request in before callback.

2010-03-22 Thread Dr. Loboto
Yes, documentation about this option is misleading.

On Mar 22, 11:10 pm, Karsten Backhaus  wrote:
> Didn't know any javascript is being evaluated in this option. Thanks
> for the hint.
>
> On 22 Mrz., 18:00, "Dr. Loboto"  wrote:
>
>
>
> > In "with" option you can add any JS code that should return well-
> > formed "name1=value1&name2=value2" string. Value of this option is not
> > escaped by Cake.
>
> > On Mar 22, 8:39 pm, Karsten Backhaus  wrote:
>
> > > I wonder if it is possible to add postdata to the ajax request before
> > > it is send to the server. Currently I simply add hidden form-fields to
> > > the formular which is supposed to be sent to the server though that's
> > > pretty slow as the browser has to rebuild the dom everytime I add
> > > something to the tree.
>
> > > So I would like to add custom data to the request which are not known
> > > beforehand.
>
> > > By the way I'm using CakePHP 1.2.4.8284 and scriptaculous.
>
> > > Utilizing the ajax->form helper.
>
> > > with kind regards
> > > K. Backhaus

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.


Re: Adding postdata to a ajax request in before callback.

2010-03-22 Thread Karsten Backhaus
Didn't know any javascript is being evaluated in this option. Thanks
for the hint.

On 22 Mrz., 18:00, "Dr. Loboto"  wrote:
> In "with" option you can add any JS code that should return well-
> formed "name1=value1&name2=value2" string. Value of this option is not
> escaped by Cake.
>
> On Mar 22, 8:39 pm, Karsten Backhaus  wrote:
>
> > I wonder if it is possible to add postdata to the ajax request before
> > it is send to the server. Currently I simply add hidden form-fields to
> > the formular which is supposed to be sent to the server though that's
> > pretty slow as the browser has to rebuild the dom everytime I add
> > something to the tree.
>
> > So I would like to add custom data to the request which are not known
> > beforehand.
>
> > By the way I'm using CakePHP 1.2.4.8284 and scriptaculous.
>
> > Utilizing the ajax->form helper.
>
> > with kind regards
> > K. Backhaus

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.


Re: Adding postdata to a ajax request in before callback.

2010-03-22 Thread Dr. Loboto
In "with" option you can add any JS code that should return well-
formed "name1=value1&name2=value2" string. Value of this option is not
escaped by Cake.

On Mar 22, 8:39 pm, Karsten Backhaus  wrote:
> I wonder if it is possible to add postdata to the ajax request before
> it is send to the server. Currently I simply add hidden form-fields to
> the formular which is supposed to be sent to the server though that's
> pretty slow as the browser has to rebuild the dom everytime I add
> something to the tree.
>
> So I would like to add custom data to the request which are not known
> beforehand.
>
> By the way I'm using CakePHP 1.2.4.8284 and scriptaculous.
>
> Utilizing the ajax->form helper.
>
> with kind regards
> K. Backhaus

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.


Adding postdata to a ajax request in before callback.

2010-03-22 Thread Karsten Backhaus
I wonder if it is possible to add postdata to the ajax request before
it is send to the server. Currently I simply add hidden form-fields to
the formular which is supposed to be sent to the server though that's
pretty slow as the browser has to rebuild the dom everytime I add
something to the tree.

So I would like to add custom data to the request which are not known
beforehand.

By the way I'm using CakePHP 1.2.4.8284 and scriptaculous.

Utilizing the ajax->form helper.

with kind regards
K. Backhaus

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.


Re: ajax request using default.ctp instead of ajax.ctp

2010-02-11 Thread Dr. Loboto
Simple include of RequestHandler component will do all automagically.

On Feb 12, 9:17 am, NickPick  wrote:
> thanks. that worked.
>
> On Feb 11, 7:38 pm, John Andersen  wrote:
>
>
>
> > In your items controller, you have to set the layout, when you detect
> > that it is an AJAX request that you are processing.
> > See how to detect this 
> > athttp://book.cakephp.org/view/350/Obtaining-Request-Information
> > And here for the 
> > layouthttp://book.cakephp.org/view/51/Controller-Attributes#Page-related-At...
>
> > Enjoy,
> >    John
>
> > On Feb 11, 9:22 pm, NickPick  wrote:
>
> > > The below ajax request works well, but it's using default.ctp as
> > > layout file instad of ajax.ctp. How can I tell it to use ajax.ctp as
> > > layout file?
> > > thanks
>
> > >    > >                     'url'=>array(
> > >                         'controller'=>'items',
> > >                         'action'=>'view',
> > >                         'before'=>'startLoading()',
> > >                         $item['Item']['id']
> > >                         ),
> > >                     'update'=>'item_view');
> > >                 ?>
> > >                 link('Show the details now','/items/
> > > view/'.$item['Item']['id'],$options);?>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: ajax request using default.ctp instead of ajax.ctp

2010-02-11 Thread NickPick
thanks. that worked.

On Feb 11, 7:38 pm, John Andersen  wrote:
> In your items controller, you have to set the layout, when you detect
> that it is an AJAX request that you are processing.
> See how to detect this 
> athttp://book.cakephp.org/view/350/Obtaining-Request-Information
> And here for the 
> layouthttp://book.cakephp.org/view/51/Controller-Attributes#Page-related-At...
>
> Enjoy,
>    John
>
> On Feb 11, 9:22 pm, NickPick  wrote:
>
> > The below ajax request works well, but it's using default.ctp as
> > layout file instad of ajax.ctp. How can I tell it to use ajax.ctp as
> > layout file?
> > thanks
>
> >    >                     'url'=>array(
> >                         'controller'=>'items',
> >                         'action'=>'view',
> >                         'before'=>'startLoading()',
> >                         $item['Item']['id']
> >                         ),
> >                     'update'=>'item_view');
> >                 ?>
> >                 link('Show the details now','/items/
> > view/'.$item['Item']['id'],$options);?>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: ajax request using default.ctp instead of ajax.ctp

2010-02-11 Thread John Andersen
In your items controller, you have to set the layout, when you detect
that it is an AJAX request that you are processing.
See how to detect this at 
http://book.cakephp.org/view/350/Obtaining-Request-Information
And here for the layout
http://book.cakephp.org/view/51/Controller-Attributes#Page-related-Attributes-layout-and-pageTitle-54

Enjoy,
   John

On Feb 11, 9:22 pm, NickPick  wrote:
> The below ajax request works well, but it's using default.ctp as
> layout file instad of ajax.ctp. How can I tell it to use ajax.ctp as
> layout file?
> thanks
>
>                        'url'=>array(
>                         'controller'=>'items',
>                         'action'=>'view',
>                         'before'=>'startLoading()',
>                         $item['Item']['id']
>                         ),
>                     'update'=>'item_view');
>                 ?>
>                 link('Show the details now','/items/
> view/'.$item['Item']['id'],$options);?>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


ajax request using default.ctp instead of ajax.ctp

2010-02-11 Thread NickPick
The below ajax request works well, but it's using default.ctp as
layout file instad of ajax.ctp. How can I tell it to use ajax.ctp as
layout file?
thanks

  array(
'controller'=>'items',
'action'=>'view',
'before'=>'startLoading()',
$item['Item']['id']
),
'update'=>'item_view');
?>
link('Show the details now','/items/
view/'.$item['Item']['id'],$options);?>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Hiding an element based on data returned in Ajax request

2009-11-16 Thread lauraw
Well, I don't know how I ever got along without Firebug! Thanks for
that Dave!!

The good news is I found a workaround (at the very bottom here). The
not so good news is that it looks like if you're updating multiple
elements as part of an ajax request and you're complete callback
depends on the values in the updated elements, you can't use the
'complete' option. Unless someone has already discovered this and
knows how to get it to work?

So, here's what I've found. Because I'm updating multiple elements
with the ajax call, the response text that's generated is a javascript
code bock:


//<![CDATA[
var __ajaxUpdater__ = {name_div:"1",
pstyle_div:"%3Cselect%20name%3D%22data%5BProductStyle%5D%5Bid%5D
%22%20id%3D%22pstyle_sel%22%3E%0A%3Coption%20value%3D%228%22%3EChunk%3C
%2Foption%3E%0A%3C%2Fselect%3E"};
for (n in __ajaxUpdater__) { if (typeof __ajaxUpdater__[n] == "string"
&& $(n)) Element.update($(n), unescape(decodeURIComponent
(__ajaxUpdater__[n]))); }
//]]>


This script code is generated by AjaxHelper.afterRender().  So, after
prototype.js has 'complete'd it updates a temporary div (output by
$ajax->observeField()) and calls the callback function - my updateInfo
(). It seems that although the request is 'complete' my callback is
being invoked before the javascript code from the ajax response is
evaluated/executed.

So, here's my workaround. Instead of specifying a callback for
'complete' in observeField(), I added the javascript code block to the
div that's getting updated.

Here's the observeField() code:

echo $form->select
('Brand.id',
$brands,
null,
array(  'id' => 'brnd_sel'),
'Choose Department');

$options = array('url' => 
'/test/getdata',

'update' => array('name_div', 'pstyle_div'),

'type' => 'asynchronous',

'indicator' => 'loading');

echo $ajax->observeField('brnd_sel', 
$options);

And here's one of the div's that's getting updated:


Product Style:

div('pstyle_div');
echo $form->select('ProductStyle.id',
array($pstyle_options),
null,
array('id' => 
'pstyle_sel'),
null);
echo $javascript->codeBlock("
if 
($('pstyle_sel').options.length == 0)

$('product_style_dsp').hide();
else

$('product_style_dsp').show();
");
echo $javascript->blockEnd();
echo $ajax->divEnd('pstyle_div');
?>



--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Hiding an element based on data returned in Ajax request

2009-11-14 Thread lauraw
Thanks, Dave! I'll check that out. Makes complete sense. Oh, I found
the $ajax->div() and $ajax->divEnd() methods in the cake 1.2 api
documentation. That was a little while ago, but if I remember
correctly, my ajax calls weren't updating the selection box data until
I enclosed them in ajax divs.

laura

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Hiding an element based on data returned in Ajax request

2009-11-14 Thread lauraw
Scott, here is observeField() code below that triggers a call in the
controller to get product categories, classes, types, brands, styles
and sub-brands. And from David's response I need to change the
'loaded' option to 'complete' and figure out what kind of javascript
error I'm getting...

echo $form->select('Product.department_id',
$departments,
null,
array(  'id' => 'dept_sel'),
'Choose Department');

$options = array('url' => '/products/getcategories',
'update' => array(  'cat_div',

'pclass_div',

'ptyp_div',

'brnd_div',

'pstyle_div',

'sub_brnd_div'),
'type' => 'asynchronous',
'loaded' => 'updateInfo();',
'indicator' => 'loading');

echo $ajax->observeField('dept_sel', $options);

The pstyle table row is:


Product Style:

div('pstyle_div');
echo 
$form->select('Product.product_style_id',
array($pstyle_options),
null,
array('id' => 
'pstyle_sel'),
null);
echo $ajax->divEnd('pstyle_div');
?>



And updateInfo() is:

echo $javascript->codeBlock("
function updateInfo()
{
if ($('pstyle_sel').length == 0)
$('product_style_dsp').hide();
else
$('product_style_dsp').show();
}
");
echo $javascript->blockEnd();

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Hiding an element based on data returned in Ajax request

2009-11-14 Thread David Roda
Also, looking at your code if you have more then one div named pstyle_sel
then the code will not function as intended.  There are two work arounds for
this.

You can either place something in the view to name the div based on a unique
value such as the item id

and then use this value in your javascript as well:
'complete'=>' if ( $("pstyle_sel' . $data['Item']['id'] . '").length == 0)
 $("style' . $data['Item']['id'] . '").hide();'

The option is to use prototype DOM traversal methods up(), down(),
previous(), next() .  You can read more about them here:
http://www.phpriot.com/articles/beginning-with-prototype/5

hth,

Dave

On Sat, Nov 14, 2009 at 2:56 AM, David Roda  wrote:

> If the loading div is not hiding it means that the javascript in the
> complete method is throwing an error so the scripts stop running.
>
> I recommend using the Firebug extension for mozilla firefox.  After
> installing it you can select the "console" tab.  This will display any
> javascript errors as well as let you run standalone javascript commands for
> testing.
>
> I believe the 'loaded' command is a bit of a misnomer.  They mention it in
> the documentation.  It actually fires after the data is loaded but before
> the view is rendered so it makes sense that it is working off of your the
> previous value
>
>
> On Fri, Nov 13, 2009 at 8:10 PM, lauraw  wrote:
>
>> Okay, bear with me ... I'm learning cake, javascript, and ajax all at
>> the same time :-) ... and prototype
>>
>> I added 'loaded' for observeField() and the javascript code to check
>> the length of the select element
>>
>> if ( $("pstyle_sel").length == 0)
>>  $("style").hide();
>>
>> this kind of works. The first time I select something that doesn't
>> have styles, it doesn't hide the row. Next I selected something that
>> did have styles and it HID THE ROW. It's like it's seeing the data
>> from the previous ajax request, like it's one step behind?
>>
>> I'm using 'loaded' instead of 'complete' because when I used
>> 'complete' my ajax loading indicator just kept displaying even though
>> the request was done.
>>
>> Any ideas on why my javascript is lagging? Or have you seen this
>> continual ajax loading indicator when using 'complete'?
>>
>> Thanks, guys for your input!
>>
>> --
>>
>> You received this message because you are subscribed to the Google Groups
>> "CakePHP" group.
>> To post to this group, send email to cake-...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/cake-php?hl=.
>>
>>
>>
>

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Hiding an element based on data returned in Ajax request

2009-11-13 Thread David Roda
If the loading div is not hiding it means that the javascript in the
complete method is throwing an error so the scripts stop running.

I recommend using the Firebug extension for mozilla firefox.  After
installing it you can select the "console" tab.  This will display any
javascript errors as well as let you run standalone javascript commands for
testing.

I believe the 'loaded' command is a bit of a misnomer.  They mention it in
the documentation.  It actually fires after the data is loaded but before
the view is rendered so it makes sense that it is working off of your the
previous value

On Fri, Nov 13, 2009 at 8:10 PM, lauraw  wrote:

> Okay, bear with me ... I'm learning cake, javascript, and ajax all at
> the same time :-) ... and prototype
>
> I added 'loaded' for observeField() and the javascript code to check
> the length of the select element
>
> if ( $("pstyle_sel").length == 0)
>  $("style").hide();
>
> this kind of works. The first time I select something that doesn't
> have styles, it doesn't hide the row. Next I selected something that
> did have styles and it HID THE ROW. It's like it's seeing the data
> from the previous ajax request, like it's one step behind?
>
> I'm using 'loaded' instead of 'complete' because when I used
> 'complete' my ajax loading indicator just kept displaying even though
> the request was done.
>
> Any ideas on why my javascript is lagging? Or have you seen this
> continual ajax loading indicator when using 'complete'?
>
> Thanks, guys for your input!
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-...@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/cake-php?hl=.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Hiding an element based on data returned in Ajax request

2009-11-13 Thread Scott Dahl
Can you post your entire observeField() code?

On 11/13/09, lauraw  wrote:
> Okay, bear with me ... I'm learning cake, javascript, and ajax all at
> the same time :-) ... and prototype
>
> I added 'loaded' for observeField() and the javascript code to check
> the length of the select element
>
>  if ( $("pstyle_sel").length == 0)
>   $("style").hide();
>
> this kind of works. The first time I select something that doesn't
> have styles, it doesn't hide the row. Next I selected something that
> did have styles and it HID THE ROW. It's like it's seeing the data
> from the previous ajax request, like it's one step behind?
>
> I'm using 'loaded' instead of 'complete' because when I used
> 'complete' my ajax loading indicator just kept displaying even though
> the request was done.
>
> Any ideas on why my javascript is lagging? Or have you seen this
> continual ajax loading indicator when using 'complete'?
>
> Thanks, guys for your input!
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-...@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cake-php?hl=.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Hiding an element based on data returned in Ajax request

2009-11-13 Thread lauraw
Okay, bear with me ... I'm learning cake, javascript, and ajax all at
the same time :-) ... and prototype

I added 'loaded' for observeField() and the javascript code to check
the length of the select element

 if ( $("pstyle_sel").length == 0)
  $("style").hide();

this kind of works. The first time I select something that doesn't
have styles, it doesn't hide the row. Next I selected something that
did have styles and it HID THE ROW. It's like it's seeing the data
from the previous ajax request, like it's one step behind?

I'm using 'loaded' instead of 'complete' because when I used
'complete' my ajax loading indicator just kept displaying even though
the request was done.

Any ideas on why my javascript is lagging? Or have you seen this
continual ajax loading indicator when using 'complete'?

Thanks, guys for your input!

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Hiding an element based on data returned in Ajax request

2009-11-13 Thread David Roda
I'm not sure what your $ajax->div tags are doing because I can't locate that
method in the documentation.

To expand on what John said, you will need to add a value to your $options
array in the AjaxHelper method which requests the function

without any other options it would look something like this

$options = array('complete'=>'if(CHECK IF AJAX RETURNED NULL)
$("style").hide();');

the placement of the $options array parameter depends on the Ajax method, so
check http://book.cakephp.org/view/212/Methods to find out where this value
goes.

Be sure to note the *double quotes* around the $("style") .  This is to keep
from breaking the single quotes around the PHP method.  You could also do
something like $(\'style\').hide();

I hope this helps,

Dave

On Fri, Nov 13, 2009 at 4:32 PM, John Andersen wrote:

> In your javascript which handles the ajax result, just find the node
> (your  element) and set the display property to none.
> Enjoy,
>John
>
> On Nov 13, 7:28 pm, lauraw  wrote:
> > I have a row that includes a form selection of product styles and is
> > being updated via an ajax->observeField. The update is working great,
> > but I would like to be able to hide the row if no styles are returned
> > by the Ajax request.
> >
> > My view code is:
> >
> > 
> > Product Style:
> > 
> >  > echo $ajax->div('pstyle_div');
> > echo
> $form->select('Product.product_style_id',
> >
> array($pstyle_options),
> > null,
> > array('id' =>
> 'pstyle_sel'),
> > null);
> > echo $ajax->divEnd('pstyle_div');
> > ?>
> > 
> > 
> >
> > I'd like to hide the  element above if $pstyle_options
> > is empty.
> >
> > Does anyone know a good way to do this?
> > Thanks!
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-...@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/cake-php?hl=.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Hiding an element based on data returned in Ajax request

2009-11-13 Thread John Andersen
In your javascript which handles the ajax result, just find the node
(your  element) and set the display property to none.
Enjoy,
   John

On Nov 13, 7:28 pm, lauraw  wrote:
> I have a row that includes a form selection of product styles and is
> being updated via an ajax->observeField. The update is working great,
> but I would like to be able to hide the row if no styles are returned
> by the Ajax request.
>
> My view code is:
>
> 
>         Product Style:
>         
>                                                          echo $ajax->div('pstyle_div');
>                                         echo 
> $form->select('Product.product_style_id',
>                                                         
> array($pstyle_options),
>                                                         null,
>                                                         array('id' => 
> 'pstyle_sel'),
>                                                         null);
>                                         echo $ajax->divEnd('pstyle_div');
>                 ?>
>         
> 
>
> I'd like to hide the  element above if $pstyle_options
> is empty.
>
> Does anyone know a good way to do this?
> Thanks!

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Hiding an element based on data returned in Ajax request

2009-11-13 Thread lauraw
I have a row that includes a form selection of product styles and is
being updated via an ajax->observeField. The update is working great,
but I would like to be able to hide the row if no styles are returned
by the Ajax request.

My view code is:


Product Style:

div('pstyle_div');
echo 
$form->select('Product.product_style_id',
array($pstyle_options),
null,
array('id' => 
'pstyle_sel'),
null);
echo $ajax->divEnd('pstyle_div');
?>



I'd like to hide the  element above if $pstyle_options
is empty.

Does anyone know a good way to do this?
Thanks!

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Helpers and AJAX request

2009-11-09 Thread Amit

Thanks! That makes sense.

On Nov 9, 7:46 pm, "Dr. Loboto"  wrote:
> You should not return from controller but use view to render AJAX
> response.
>
> On Nov 9, 9:51 pm, Amit  wrote:
>
>
>
> > The general question is - Is there a way to access Helpers during an
> > AJAX response?
>
> > I have a form that contains a dropdown and a group of radio buttons.
> > When a new item is selected from the dropdown, an XMLHTTPRequest is
> > sent to the server to get the new collection of radio buttons.
>
> > Right now, my controller determines if its an AJAX request, queries
> > for the list of items, manually generates the HTML for the radio
> > buttons, and sends the response. I know that the View layer offers a
> > FormHelper to "automagically" create the form element ($form->radio
> > ()), is there anything similar available when creating an AJAX
> > response?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Helpers and AJAX request

2009-11-09 Thread Dr. Loboto

You should not return from controller but use view to render AJAX
response.

On Nov 9, 9:51 pm, Amit  wrote:
> The general question is - Is there a way to access Helpers during an
> AJAX response?
>
> I have a form that contains a dropdown and a group of radio buttons.
> When a new item is selected from the dropdown, an XMLHTTPRequest is
> sent to the server to get the new collection of radio buttons.
>
> Right now, my controller determines if its an AJAX request, queries
> for the list of items, manually generates the HTML for the radio
> buttons, and sends the response. I know that the View layer offers a
> FormHelper to "automagically" create the form element ($form->radio
> ()), is there anything similar available when creating an AJAX
> response?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Helpers and AJAX request

2009-11-09 Thread Amit

The general question is - Is there a way to access Helpers during an
AJAX response?

I have a form that contains a dropdown and a group of radio buttons.
When a new item is selected from the dropdown, an XMLHTTPRequest is
sent to the server to get the new collection of radio buttons.

Right now, my controller determines if its an AJAX request, queries
for the list of items, manually generates the HTML for the radio
buttons, and sends the response. I know that the View layer offers a
FormHelper to "automagically" create the form element ($form->radio
()), is there anything similar available when creating an AJAX
response?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: "null" response on Ajax request

2009-10-29 Thread Dr. Loboto

To avoid such problems I set debug to 0 at the very end of AJAX view/
layout. So If there are errors - I see them and can fix, if there are
no errors - response is clear of debug data.

On Oct 29, 5:55 pm, Thanos Atskakanis
 wrote:
> it was set to 2 but AjaxHandler component was setting it back to 0 -
> disabled it and found out that the problem was coming from a missing file in
> the live server - rookie error :o)
>
> thanks a lot for that
>
>
>
> On Thu, Oct 29, 2009 at 4:04 AM, Dr. Loboto  wrote:
>
> > Set debug to at least 1 (and no matter that it is ajax) to see error.
>
> > On Oct 28, 10:34 pm, Thanos Atskakanis
> >  wrote:
> > > Hi all,
>
> > > I am currently building a CMS and my system does some ajax requests which
> > > return some html: simple and nice.
> > > When I run it locally it all works fine but when I put it live instead of
> > > the expected html I get "null". Not "Not found" or any other error, just
> > the
> > > word "null".
>
> > > All I use is the RequestHandler component and the following line of code:
> > > $this->render('/path/to/element');
> > > I also use milesjohnson's AjaxHandler component somewhere else in my
> > > controller, but it doesn't seem to be the problem because I tested
> > without
> > > it and everything was fine...
>
> > > Here are the response headers I get in both servers:
>
> > > Live ("null" response):
>
> > > DateWed, 28 Oct 2009 16:08:26
> > GMTServerApacheX-Powered-ByPHP/5.2.11P3PCP="NOI
> > > ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"Set-CookieCAKEPHP=deleted;
> > > expires=Tue, 28-Oct-2008 16:08:26 GMT; path=/
> > > CAKEPHP=0svbs500eu74f9613mjd02sn71;
> > > path=/Content-Length4ConnectioncloseContent-Typetext/html; charset=UTF-8
>
> > > Locally (normal html response):
>
> > > DateWed, 28 Oct 2009 16:08:35 GMTServerApache/2.2.12 (Ubuntu)X-Powered-By
> > > PHP/5.2.10-2ubuntu4P3PCP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
> > > Set-CookieCAKEPHP=deleted; expires=Tue, 28-Oct-2008 16:08:35 GMT;
> > > path=/johnross CAKEPHP=c37700dbbbf3d009cfa920695637118a; path=/mypathVary
> > > Accept-EncodingContent-EncodinggzipContent-Length50Keep-Alivetimeout=15,
> > > max=87ConnectionKeep-AliveContent-Typetext/html; charset=UTF-8
>
> > > Anyone who came across a similar situation?
>
> > > Thanks,
> > > Thanos
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: "null" response on Ajax request

2009-10-29 Thread Thanos Atskakanis
it was set to 2 but AjaxHandler component was setting it back to 0 -
disabled it and found out that the problem was coming from a missing file in
the live server - rookie error :o)

thanks a lot for that



On Thu, Oct 29, 2009 at 4:04 AM, Dr. Loboto  wrote:

>
> Set debug to at least 1 (and no matter that it is ajax) to see error.
>
> On Oct 28, 10:34 pm, Thanos Atskakanis
>  wrote:
> > Hi all,
> >
> > I am currently building a CMS and my system does some ajax requests which
> > return some html: simple and nice.
> > When I run it locally it all works fine but when I put it live instead of
> > the expected html I get "null". Not "Not found" or any other error, just
> the
> > word "null".
> >
> > All I use is the RequestHandler component and the following line of code:
> > $this->render('/path/to/element');
> > I also use milesjohnson's AjaxHandler component somewhere else in my
> > controller, but it doesn't seem to be the problem because I tested
> without
> > it and everything was fine...
> >
> > Here are the response headers I get in both servers:
> >
> > Live ("null" response):
> >
> > DateWed, 28 Oct 2009 16:08:26
> GMTServerApacheX-Powered-ByPHP/5.2.11P3PCP="NOI
> > ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"Set-CookieCAKEPHP=deleted;
> > expires=Tue, 28-Oct-2008 16:08:26 GMT; path=/
> > CAKEPHP=0svbs500eu74f9613mjd02sn71;
> > path=/Content-Length4ConnectioncloseContent-Typetext/html; charset=UTF-8
> >
> > Locally (normal html response):
> >
> > DateWed, 28 Oct 2009 16:08:35 GMTServerApache/2.2.12 (Ubuntu)X-Powered-By
> > PHP/5.2.10-2ubuntu4P3PCP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
> > Set-CookieCAKEPHP=deleted; expires=Tue, 28-Oct-2008 16:08:35 GMT;
> > path=/johnross CAKEPHP=c37700dbbbf3d009cfa920695637118a; path=/mypathVary
> > Accept-EncodingContent-EncodinggzipContent-Length50Keep-Alivetimeout=15,
> > max=87ConnectionKeep-AliveContent-Typetext/html; charset=UTF-8
> >
> > Anyone who came across a similar situation?
> >
> > Thanks,
> > Thanos
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: "null" response on Ajax request

2009-10-28 Thread Dr. Loboto

Set debug to at least 1 (and no matter that it is ajax) to see error.

On Oct 28, 10:34 pm, Thanos Atskakanis
 wrote:
> Hi all,
>
> I am currently building a CMS and my system does some ajax requests which
> return some html: simple and nice.
> When I run it locally it all works fine but when I put it live instead of
> the expected html I get "null". Not "Not found" or any other error, just the
> word "null".
>
> All I use is the RequestHandler component and the following line of code:
> $this->render('/path/to/element');
> I also use milesjohnson's AjaxHandler component somewhere else in my
> controller, but it doesn't seem to be the problem because I tested without
> it and everything was fine...
>
> Here are the response headers I get in both servers:
>
> Live ("null" response):
>
> DateWed, 28 Oct 2009 16:08:26 GMTServerApacheX-Powered-ByPHP/5.2.11P3PCP="NOI
> ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"Set-CookieCAKEPHP=deleted;
> expires=Tue, 28-Oct-2008 16:08:26 GMT; path=/
> CAKEPHP=0svbs500eu74f9613mjd02sn71;
> path=/Content-Length4ConnectioncloseContent-Typetext/html; charset=UTF-8
>
> Locally (normal html response):
>
> DateWed, 28 Oct 2009 16:08:35 GMTServerApache/2.2.12 (Ubuntu)X-Powered-By
> PHP/5.2.10-2ubuntu4P3PCP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
> Set-CookieCAKEPHP=deleted; expires=Tue, 28-Oct-2008 16:08:35 GMT;
> path=/johnross CAKEPHP=c37700dbbbf3d009cfa920695637118a; path=/mypathVary
> Accept-EncodingContent-EncodinggzipContent-Length50Keep-Alivetimeout=15,
> max=87ConnectionKeep-AliveContent-Typetext/html; charset=UTF-8
>
> Anyone who came across a similar situation?
>
> Thanks,
> Thanos
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



"null" response on Ajax request

2009-10-28 Thread Thanos Atskakanis
Hi all,

I am currently building a CMS and my system does some ajax requests which
return some html: simple and nice.
When I run it locally it all works fine but when I put it live instead of
the expected html I get "null". Not "Not found" or any other error, just the
word "null".

All I use is the RequestHandler component and the following line of code:
$this->render('/path/to/element');
I also use milesjohnson's AjaxHandler component somewhere else in my
controller, but it doesn't seem to be the problem because I tested without
it and everything was fine...

Here are the response headers I get in both servers:

Live ("null" response):

DateWed, 28 Oct 2009 16:08:26 GMTServerApacheX-Powered-ByPHP/5.2.11P3PCP="NOI
ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"Set-CookieCAKEPHP=deleted;
expires=Tue, 28-Oct-2008 16:08:26 GMT; path=/
CAKEPHP=0svbs500eu74f9613mjd02sn71;
path=/Content-Length4ConnectioncloseContent-Typetext/html; charset=UTF-8


Locally (normal html response):

DateWed, 28 Oct 2009 16:08:35 GMTServerApache/2.2.12 (Ubuntu)X-Powered-By
PHP/5.2.10-2ubuntu4P3PCP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Set-CookieCAKEPHP=deleted; expires=Tue, 28-Oct-2008 16:08:35 GMT;
path=/johnross CAKEPHP=c37700dbbbf3d009cfa920695637118a; path=/mypathVary
Accept-EncodingContent-EncodinggzipContent-Length50Keep-Alivetimeout=15,
max=87ConnectionKeep-AliveContent-Typetext/html; charset=UTF-8













Anyone who came across a similar situation?

Thanks,
Thanos

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Is Ajax request

2009-10-22 Thread Dave Maharaj :: WidePixels.com

Yeah all links are the same. Same class and jquery grabs by the class to
load it ajax. But I said screw it and just included 'all' into the
filterByType function so it will pull it that way. 

-Original Message-
From: John Andersen [mailto:j.andersen...@gmail.com] 
Sent: October-22-09 7:42 AM
To: CakePHP
Subject: Re: Is Ajax request


How is the HTML looking? Does it look the same as the other links?
Enjoy,
   John

On Oct 21, 6:59 pm, "Dave Maharaj :: WidePixels.com"
 wrote:
> I have this function where its first called normally by a link (http 
> request). Once loaded the pagination links are done via Ajax. I have 
> 'all', 'new', 'archive' links which all get called to paginate the 
> result using Ajax and jquery. Problem is when i go to posts/index it 
> works fine, click 'all' which loads index it loads the layout too. The 
> other links all work fine and load the element except "all"
>
> function index() {
>         if ($this->RequestHandler->isAjax()) {
>                 //code for view
>                 $this->layout = 'ajax';
>                 $this->viewPath = 'elements/posts';
>                 $this->render(paginate');
>
>           }
>         if (!$this->RequestHandler->isAjax()) {
>                 //code for view
>                 $this->layout = 'default_left';
>                 $this->render('index');
>
>           }
>
> }
>
> so this here will filter the posts depending on what the user clicked 
> 'all', 'new', 'archive'
> But 'all' when clicked always returns the 'default_left' layout
>
> function filterByType($type = null) {
>           if ($this->RequestHandler->isAjax()) {
>               $this->paginate['Post'] = 
> $this->Post->filterByTypePagination($this->auth_id, $this->rank, 
> $type, $this->post_display);
>               $this->set('posts', $this->paginate());
>               $this->layout = 'ajax';
>               $this->viewPath = 'elements/posts';
>               $this->render('paginate');
>           } else {
>               $this->redirect(array('action' => 'index'));
>           }
>       }
>
> Cann someone point out where I am going wrong? I tried if 
> ($this->RequestHandler->isAjax()) {
>                 //code for view
>                 $this->layout = 'ajax';
>                 $this->viewPath = 'elements/posts';
>                 $this->render(paginate');
>
>           } else {
>
>                 //code for view
>                 $this->layout = 'default_left';
>                 $this->render('index');
>
> }
>
> but same thing keeps happening.
>
> Dave


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Is Ajax request

2009-10-22 Thread John Andersen

How is the HTML looking? Does it look the same as the other links?
Enjoy,
   John

On Oct 21, 6:59 pm, "Dave Maharaj :: WidePixels.com"
 wrote:
> I have this function where its first called normally by a link (http
> request). Once loaded the pagination links are done via Ajax. I have 'all',
> 'new', 'archive' links which all get called to paginate the result using
> Ajax and jquery. Problem is when i go to posts/index it works fine, click
> 'all' which loads index it loads the layout too. The other links all work
> fine and load the element except "all"
>
> function index() {
>         if ($this->RequestHandler->isAjax()) {
>                 //code for view
>                 $this->layout = 'ajax';
>                 $this->viewPath = 'elements/posts';
>                 $this->render(paginate');
>
>           }
>         if (!$this->RequestHandler->isAjax()) {
>                 //code for view            
>                 $this->layout = 'default_left';
>                 $this->render('index');
>
>           }
>
> }
>
> so this here will filter the posts depending on what the user clicked 'all',
> 'new', 'archive'
> But 'all' when clicked always returns the 'default_left' layout
>
> function filterByType($type = null) {
>           if ($this->RequestHandler->isAjax()) {
>               $this->paginate['Post'] =
> $this->Post->filterByTypePagination($this->auth_id, $this->rank, $type,
> $this->post_display);
>               $this->set('posts', $this->paginate());
>               $this->layout = 'ajax';
>               $this->viewPath = 'elements/posts';
>               $this->render('paginate');
>           } else {
>               $this->redirect(array('action' => 'index'));
>           }
>       }
>
> Cann someone point out where I am going wrong? I tried
> if ($this->RequestHandler->isAjax()) {
>                 //code for view
>                 $this->layout = 'ajax';
>                 $this->viewPath = 'elements/posts';
>                 $this->render(paginate');
>
>           } else {
>
>                 //code for view            
>                 $this->layout = 'default_left';
>                 $this->render('index');
>
> }
>
> but same thing keeps happening.
>
> Dave
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Is Ajax request

2009-10-21 Thread Dave Maharaj :: WidePixels.com

I have this function where its first called normally by a link (http
request). Once loaded the pagination links are done via Ajax. I have 'all',
'new', 'archive' links which all get called to paginate the result using
Ajax and jquery. Problem is when i go to posts/index it works fine, click
'all' which loads index it loads the layout too. The other links all work
fine and load the element except "all"
 
function index() {
if ($this->RequestHandler->isAjax()) {
//code for view
$this->layout = 'ajax';
$this->viewPath = 'elements/posts';
$this->render(paginate');
  
  } 
if (!$this->RequestHandler->isAjax()) {
//code for view 
$this->layout = 'default_left';
$this->render('index');
 
  }

}
so this here will filter the posts depending on what the user clicked 'all',
'new', 'archive'
But 'all' when clicked always returns the 'default_left' layout

function filterByType($type = null) {
  if ($this->RequestHandler->isAjax()) {
  $this->paginate['Post'] =
$this->Post->filterByTypePagination($this->auth_id, $this->rank, $type,
$this->post_display);
  $this->set('posts', $this->paginate());
  $this->layout = 'ajax';
  $this->viewPath = 'elements/posts';
  $this->render('paginate');
  } else {
  $this->redirect(array('action' => 'index'));
  }
  }

Cann someone point out where I am going wrong? I tried 
if ($this->RequestHandler->isAjax()) {
//code for view
$this->layout = 'ajax';
$this->viewPath = 'elements/posts';
$this->render(paginate');
  
  } else {

//code for view 
$this->layout = 'default_left';
$this->render('index');

} 
but same thing keeps happening.
 
Dave


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: CakePHP Timeout when sending Ajax-Request?

2009-07-28 Thread brian

A timeout where? In Cake, or javascript? I don't kow about Prototype
(what Cake's AjaxHelper uses), but jQuery allows to set a timeout.

But you should ensure that you have debug set to 0, first of all. That
will always slow things down somewhat. Also, look into
caching--perhaps the problem is due to a very inefficient query. But,
without knowing more about your problem, there's not much more anyone
can say.

On Tue, Jul 28, 2009 at 3:21 AM, moe wrote:
>
> Does nobody know how to solve this problem?
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: CakePHP Timeout when sending Ajax-Request?

2009-07-28 Thread moe

Does nobody know how to solve this problem?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Redirect after AJAX request

2009-07-24 Thread NOSLOW

hey DatacenterHellas,

Your best bet is to not login via an AJAX call. Just set
"standardSubmit: true" in your ExtJS login FormPanel config and call
"MyFormPanel.getForm().submit({method: 'POST'});". Now you can let
CakePHP handler your redirects server-side. On failure, you login page
will just reload. This works very well for me.

Here's some ExtJS code showing details of the login form:

Ext.namespace('CRM');
var crmLogin = {};
Ext.onReady(function(){

var crm_center = new Ext.Panel({
region: 'center',
layout: 'fit',
bodyBorder: false, border: false, hideBorders: true,
collapsible: false,
bodyStyle: 'border-style: none;',
width: 300,
items:
[
{
contentEl: 'center1'
}
]
});

var viewport = new Ext.Viewport({
layout: 'border',
items:
[
new Ext.BoxComponent({
title: 'North',
region: 'north',
el: 'north',
height: 80
}), new Ext.BoxComponent({
title: 'South',
region: 'south',
el: 'footer',
height: 30
}),
crm_center
]
});

Ext.QuickTips.init();

crmLogin = new Ext.FormPanel({
labelWidth: 70,
url: '/users/login',
frame: true,
title: 'Application Login',
width: 284,
bodyStyle: 'padding: 10px 0 5px 20px;',
defaultType: 'textfield',
standardSubmit: true,
monitorValid: true,

items:
[
{
name: '_method',
xtype: 'hidden',
value: 'POST'
},{
id: 'CRM-username',
fieldLabel: 'Username',
name: 'data[User][username]',
allowBlank: false
},{
id: 'CRM-password',
fieldLabel: 'Password',
name: 'data[User][password]',
inputType: 'password',
allowBlank: false
}
],

buttons:
[
{
text: 'Login',
formBind: true,
type: 'submit',
handler: function() {
CRM.login(crmLogin);
}
}
]
});

var win = new Ext.Window({
layout: 'fit',
width: 300,
height: 150,
closable: false,
resizable: false,
plain: true,
items: crmLogin
});

// defer delay seems to help with rendering of login form
(sometimes button is placed too low on form).
(function(){
win.show();
var mapPassword = new Ext.KeyMap('CRM-password', {
key: 13, // or Ext.EventObject.ENTER
fn: function() {CRM.login(crmLogin);}
,scope: crmLogin
});

var mapUsername = new Ext.KeyMap('CRM-username', {
key: 13, // or Ext.EventObject.ENTER
fn: function() {CRM.login(crmLogin);}
,scope: crmLogin
});
}).defer(200);

(function(){
crmLogin.getForm().findField('data[User][username]').focus();
}).defer(700);
});

CRM.login = function(loginFormPanel) {
loginFormPanel.ownerCt.hide();
Ext.MessageBox.wait('Logging in...', 'Please wait...');
loginFormPanel.getForm().submit({method: 'POST'});
};

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Redirect after AJAX request

2009-07-23 Thread DatacenterHellas

Thanks all of you for your assistance :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Redirect after AJAX request

2009-07-23 Thread brian

You can't redirect from the server (PHP) when making an AJAX request.
You can only send a response back to the client. If your server code
determines that the user needs to be redirected, it should inform your
client-side code--the javascript function making the AJAX
request--that *it* should handle the redirect.


On Thu, Jul 23, 2009 at 12:52 PM,
DatacenterHellas wrote:
>
> Ok . . .
>
> this is one aproach of the problem but I think is not the most
> correct.
>
> I mean what about if the user will not enter correct data ? ? ?
>  Have I to redirect him to an action and then will return again to
> login ? ? ?
>
> Is not so nice.
>
> My project is based on CakePHP and ExtJS.
>
> For the Login I have create a form with ExtJS to send the username and
> password to CakePHP thru HTTP Post.
>
> Then from the CakePHP users controller I putting the POST values to
> $this->data['User']['username'] = $_POST['username'] and the password
> too.
>
> After that the Cake know how to login by using the Auth component.
>
> After the user is login the $this->Auth->loginRedirect is going to
> Users Index action.
>
> From the firebug I see that the request is implemented correctly but
> what I get is the same screen. My Web Browser is not updated to go to
> the Users Index action.
>
> That is what I like to do.
>
> Any other Idea ? ? ?
>
> Thanks a lot :)
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Redirect after AJAX request

2009-07-23 Thread DatacenterHellas

Ok . . .

this is one aproach of the problem but I think is not the most
correct.

I mean what about if the user will not enter correct data ? ? ?
 Have I to redirect him to an action and then will return again to
login ? ? ?

Is not so nice.

My project is based on CakePHP and ExtJS.

For the Login I have create a form with ExtJS to send the username and
password to CakePHP thru HTTP Post.

Then from the CakePHP users controller I putting the POST values to
$this->data['User']['username'] = $_POST['username'] and the password
too.

After that the Cake know how to login by using the Auth component.

After the user is login the $this->Auth->loginRedirect is going to
Users Index action.

>From the firebug I see that the request is implemented correctly but
what I get is the same screen. My Web Browser is not updated to go to
the Users Index action.

That is what I like to do.

Any other Idea ? ? ?

Thanks a lot :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Redirect after AJAX request

2009-07-23 Thread Dardo Sordi Bogado

window.location = url

On Thu, Jul 23, 2009 at 1:16 PM,
DatacenterHellas wrote:
>
> Hello all.
>
> How can I redirect after AJAX login to another action
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Redirect after AJAX request

2009-07-23 Thread DatacenterHellas

Hello all.

How can I redirect after AJAX login to another action
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



CakePHP Timeout when sending Ajax-Request?

2009-07-23 Thread moe

Hey,

I'm new to the CakePHP-Group. I joined, because I wasn't able to find
any help on this.

I've built a small project management interface on Cake. All actions
are done with Ajax (jQuery), so that the page doesn't have to be
reloaded. Normally the website is started at morning and remains
opened in a browser-tab all day.
The problem is that, after some time of inactivity (maybe half an hour
or so?) ajax calls fail. They are being sent by a GET-request, since
there is no sensitive data being sent and it's just a tiny request,
i.e. increase the attended time of a project by one hour.

This is the response-header of a successful call (Safari 4):

Connection:Keep-Alive
Content-Length:90
Content-Type:text/html; charset=UTF-8
Date:Thu, 23 Jul 2009 10:18:26 GMT
Keep-Alive:timeout=5, max=87
P3p:CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Server:Apache/2.2
Set-Cookie:DGPROJECTS=v6f2u4hevbg5djnvn8l2rlff01; expires=Thu, 30 Jul
2009 10:18:27 GMT; path=/
X-Powered-By:PHP/5.2.6


... and this is the response-header of the same request when failing:

Connection:Keep-Alive
Content-Length:0
Content-Type:text/html
Date:Thu, 23 Jul 2009 10:00:33 GMT
Keep-Alive:timeout=5, max=100
P3p:CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Server:Apache/2.2
X-Pad:avoid browser bug
X-Powered-By:PHP/5.2.6

After refreshing the page everything works fine. Does anybody know
help on this?!

Thanks!!

moe

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Stop AJAX Request

2009-07-15 Thread brian

If you want the login form to load in place of whatever would normally
be returned, you can simply render it (if your login form is an
element) instead of the recipe.

if ($this->Auth->user() == null)
{
$this->viewPath = 'elements/users';
$this->render('login');
}
else
{
// normal code ...
}

If you want the entire page to be refreshed to the login screen, just
send back something in the response that your JS code will check for.
If found, instead of loading the content into the page, change the
location to your login page.

On Wed, Jul 15, 2009 at 5:01 AM, Luke wrote:
>
> Hi,
>
> I am still working on my first Cake Project and I am now stuck in some
> AJAX Request where I would need some feedback.
>
> I am trying to achieve the following.
>
> I have recipes everybody can see. There is a link above the recipe to
> add it to your favorites. If you are logged in the page should check
> if you have it already saved, than the link should show "Already in
> cookbook" otherwise "Add to favorites". Next step is when you want to
> add it, you have to be logged in, otherwise the login window should
> show up.
>
> The "Add to cookbook" I wanted to do with AJAX in the background.
>
> So I am using
>
> if($this->Auth->user() == null)
> {
>      $this->redirect('/users/login');
> }
>
> in my addToFavorites($id) to check if the User is logged in, if not,
> the Login Form shows up above the recipe. But what I actually would
> like to reach is that the recipe doesn't show up at all anymore but
> instead just the Login Form. If you are than logged in, you should be
> seeing the recipe again and the link should have changed.
>
> I suppose it happens, because I am only replacing the content in the
>  with AJAX. Is there any chance to stop the AJAX response and
> instead re-load the full page or what would you guys suggest?
>
> Thanks for any advice. Luke
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Stop AJAX Request

2009-07-15 Thread Piotr Kilczuk

Hello,

> I have tried this out to understand the structure behind it but get
>
> Query: removeFavorite
>
> So it must be the below line, but what is the issue with this code?
> Why is it using the method as a query?
>
> $success = $this->Product->User->removeFavorite($id);
>
>
> I can't see what is wrong. Anyone an idea? Thanks so much in advance.

You have to have this method inside your User model, I guess you
don't. There are no automagic remove methods in Cake (but there are
magic findBy... and findAllBy... methods, which might confuse you).

As for the AJAX issue, I'd say it's possible. I'd suggest you used
JSON as a return of an ajax check, and the do the rest of the view
logic, but maybe I miss the point of your problem...


Regards,
Piotr

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Stop AJAX Request

2009-07-15 Thread Luke

Hi,

Oh, so I can not re-send the complete Page when I realise the User is
not logged in!? So I will have to re-think my idea. I really thought
that there is a possibility, but good that you have given a clear "No,
not possible"


I have now tried something out from the IBM Tutorial, its a bit of a
different issue, but I did not want to start a new post.
http://www.ibm.com/developerworks/opensource/library/os-php-cake5/index.html?S_TACT=105AGX44&S_CMP=TUT


They use the following:

function removeFromFavorites($id) {
$username = $this->Session->read('user');
$success = false;
$user = $this->Product->User->findByUsername
($username, 'User.id');
$this->Product->User->id = $user['User']['id'];
$success = $this->Product->User->removeFavorite($id);
if ( $this->RequestHandler->isAjax() ) {
echo 'Removed product from favorites';
exit;
} else {
if ( $success ) {
$this->Session->setFlash('Removed
product from favorites');
$this->redirect('/users/favorites');
} else {
$this->Session->setFlash('Access
denied');
$this->redirect('/products/index');
}
}
}


I have tried this out to understand the structure behind it but get

Query: removeFavorite

So it must be the below line, but what is the issue with this code?
Why is it using the method as a query?

$success = $this->Product->User->removeFavorite($id);


I can't see what is wrong. Anyone an idea? Thanks so much in advance.
Luke



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Stop AJAX Request

2009-07-15 Thread rchavik

IIRC, you cannot do that with AJAX requests.

Since you're already using Auth component, you can set the Auth-
>ajaxLogin variable (in your AppController) to contain the appropriate
error and handle that condition accordingly in your javascript.


On Jul 15, 4:01 pm, Luke  wrote:
> Hi,
>
> I am still working on my first Cake Project and I am now stuck in some
> AJAX Request where I would need some feedback.
>
> I am trying to achieve the following.
>
> I have recipes everybody can see. There is a link above the recipe to
> add it to your favorites. If you are logged in the page should check
> if you have it already saved, than the link should show "Already in
> cookbook" otherwise "Add to favorites". Next step is when you want to
> add it, you have to be logged in, otherwise the login window should
> show up.
>
> The "Add to cookbook" I wanted to do with AJAX in the background.
>
> So I am using
>
> if($this->Auth->user() == null)
> {
>       $this->redirect('/users/login');
>
> }
>
> in my addToFavorites($id) to check if the User is logged in, if not,
> the Login Form shows up above the recipe. But what I actually would
> like to reach is that the recipe doesn't show up at all anymore but
> instead just the Login Form. If you are than logged in, you should be
> seeing the recipe again and the link should have changed.
>
> I suppose it happens, because I am only replacing the content in the
>  with AJAX. Is there any chance to stop the AJAX response and
> instead re-load the full page or what would you guys suggest?
>
> Thanks for any advice. Luke
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Stop AJAX Request

2009-07-15 Thread Luke

Hi,

I am still working on my first Cake Project and I am now stuck in some
AJAX Request where I would need some feedback.

I am trying to achieve the following.

I have recipes everybody can see. There is a link above the recipe to
add it to your favorites. If you are logged in the page should check
if you have it already saved, than the link should show "Already in
cookbook" otherwise "Add to favorites". Next step is when you want to
add it, you have to be logged in, otherwise the login window should
show up.

The "Add to cookbook" I wanted to do with AJAX in the background.

So I am using

if($this->Auth->user() == null)
{
  $this->redirect('/users/login');
}

in my addToFavorites($id) to check if the User is logged in, if not,
the Login Form shows up above the recipe. But what I actually would
like to reach is that the recipe doesn't show up at all anymore but
instead just the Login Form. If you are than logged in, you should be
seeing the recipe again and the link should have changed.

I suppose it happens, because I am only replacing the content in the
 with AJAX. Is there any chance to stop the AJAX response and
instead re-load the full page or what would you guys suggest?

Thanks for any advice. Luke

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: ajax request after session expired - how to redirect to the front page?

2009-06-07 Thread brian

It can't be done from the server if it's an asynchronous request.
You'll have to do it with javascript. Perhaps you could send back a
particular response if you wish to redirect and have your JS callback
look for it. If it's found, use document.location = ...



On Sun, Jun 7, 2009 at 9:34 AM, MarcS wrote:
>
> Hi everyone.
>
> I have a site that is farely heavy on AJAX.
> Sometimes it happens that the Session has expired and the user needs
> to log in again.
> Is there a way that I can detect that and send the surfer to the log
> in page instead of the login page loading inside the dom container?
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



ajax request after session expired - how to redirect to the front page?

2009-06-07 Thread MarcS

Hi everyone.

I have a site that is farely heavy on AJAX.
Sometimes it happens that the Session has expired and the user needs
to log in again.
Is there a way that I can detect that and send the surfer to the log
in page instead of the login page loading inside the dom container?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Auth. with an AJAX Request

2009-05-21 Thread christo

well, i haven't done this specifically so I'm not sure I can
demonstrate exactly how, but you probably either have to allow
('addToWatchlist') in your before filter then instead test if the
request comes from a logged in user in that action before you add the
link to the watch list. If it does NOT, you can serve up a login form
in a popup window via AJAX, but you won't be redirected unless you do
some kind of javascript XML or JSON test on the response.
The reason you don't redirect is that if you let auth handle the
'behind the scenes' request, it will simply re-route the request to
your default login redirect - probably the login page - which won't do
anything at all since you aren't doing anything with the request. You
should read up on AJAX. If you want to know how to serve up a login
form with AJAX and submit it start with a basic AJAX tutorial and go
from there?

http://www.w3schools.com/Ajax/Default.Asp




On May 20, 4:21 pm, Luke  wrote:
> Hi,
>
> I am not sure what else I could copy & paste from the sourcecode. I
> only have a normal login action, in my user controller, which only
> saves the last login and thats pretty much it. An Login AJAX action?
> How would this look?
> Have you got an example?
>
> Thanks. Luke
>
> On 20 Mai, 22:18, christo  wrote:
>
> > all I can think of is that you don't have a login AJAX action set up
> > so the request dies without redirecting to a log in if you try to
> > access the link from not logged in? I dunno it's hard to tell from
> > your description. pastebin maybe?
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: If not Ajax request

2009-05-20 Thread Dr. Loboto

I always do simple - if you have link "/bookmarks/save" for AJAX it
should be "/bookmarks/save?".rand(), or my captcha images have URL "/
captcha/".rand() - concrete implementation depends on case, but idea
is in keeping URL of AJAX-dependent action always unique.

But surprised that you got this in FF. In my case only IE was
uncontrollable by headers (pragma no-cache, expires, etc).

On May 20, 11:22 pm, "Dave Maharaj :: WidePixels.com"
 wrote:
> Thanks for the tip but I do not seem to follow you on
> "If yes, only addition of any random param to form action (or whatever you
> request on "save" click) will save you."
>
> The function has no form...pretty much just a quick save "bookmark". All the
> saved data is gathered from the Auth id and the variable passed in the URL
> link in the controller.
>
> How would I implement the idea you mention?
>
> Thanks,
>
> Dave
>
> -Original Message-
> From: Dr. Loboto [mailto:drlob...@gmail.com]
> Sent: May-20-09 12:58 PM
> To: CakePHP
> Subject: Re: If not Ajax request
>
> I almost can swear that you tested it in IE and after save no actual request
> to server was done at all (can be checked in Apache access
> logs) - you saw cached result of previous save call. If yes, only addition
> of any random param to form action (or whatever you request on "save" click)
> will save you.
>
> On May 20, 9:28 pm, "Dave Maharaj :: WidePixels.com"
>  wrote:
> > I am trying to make sure the requested function is Ajax, if not
> > redirect...so if someone tries to manually enter it into the url it
> > redirects them back to the index page but not working the way i want.
> > This is what happens:
> > Scenario 1:
> > original URL: localhost/testsite/journal/256 If someone goes to the
> > page, clicks save (save entry 256)...perfect...works.
> > But if they then type in "entries/" into the url so it looks like
> > localhost/testsite/journal/entries/256 it runs the Ajax function.
>
> > Scenario 2
> > If they go to the same page localhost/testsite/journal/256 and type in
> > "entries/" into the url so it looks like
> > localhost/testsite/journal/entries/256  before saving an entry the
> > function re-directs as it should.
>
> > Why is it only redirecting for scenario 2 and not 1?
>
> > function entries($articles_id)
> >       {
>
> >           if ($this->RequestHandler->isAjax())
> >         {
>
> >             save entry code
>
> >           }else{
> >           //request is not AJAX
> >           $this->redirect(array('controller' => 'journal', 'action' =>
> > 'index'));
> >         }
> >       }
>
> > Dave
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Help with AJAX request.

2009-05-20 Thread Dave Maharaj :: WidePixels.com

I have an ajax request which works fine. I am testing out secnarios that the
end user may try in advance to see what would happen.
My link in the view;
link('  ',
array('controller'=>'journal','action'=>'quicksave',$journal['Journal']['id'
]), array('class'=>'save_me')); ?>
 
So I open firebug and remove the Journal.id from the link so it looks like
site/journal/quicksave/ instead of site/journal/quicksave/65 
 
What I need to do is ensure that there is a Journal.id when the quicksave
function runs.
 
I tried putting if (!journalID) inside the function but the view is still
rendered (blank because the url still calls quicksave)
 
Tried before filter / render
 
if ($this->action = 'quicksave')
{
debug($journal_id);
}
Results in 
Undefined variable:$journal_id
 
Tried inside the if ($this->RequestHandler->isAjax()) {
but that does nothing but render the blank view because at this point its
too late
 
How / where should I try to determine if there was no $journal_id then dont
render anything or error what not...what ever I decide.
 
Dave


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Auth. with an AJAX Request

2009-05-20 Thread Luke

Hi,

I am not sure what else I could copy & paste from the sourcecode. I
only have a normal login action, in my user controller, which only
saves the last login and thats pretty much it. An Login AJAX action?
How would this look?
Have you got an example?

Thanks. Luke

On 20 Mai, 22:18, christo  wrote:
> all I can think of is that you don't have a login AJAX action set up
> so the request dies without redirecting to a log in if you try to
> access the link from not logged in? I dunno it's hard to tell from
> your description. pastebin maybe?
>


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Auth. with an AJAX Request

2009-05-20 Thread christo

all I can think of is that you don't have a login AJAX action set up
so the request dies without redirecting to a log in if you try to
access the link from not logged in? I dunno it's hard to tell from
your description. pastebin maybe?



On May 20, 10:58 am, Luke  wrote:
> Hi,
>
> I have again read backwards and forwards through the www to find a
> solution for my problem. I am sure that there is other people running
> into the same issue. How do you guys solve it?
>
> All I want is a link saying "Add article to watchlist" which than, if
> the User is logged in writes it into the DB, Article gets shown again
> and link changes to "In watchlist" and if User is not logged in
> redirects to the Login Window with a message that you need to be
> logged in to use this feature. All this should happen with AJAX. My
> normal login is happening with Auth. and the typical stuff in the
> beforeFilter() of the app_controller. In the watchlist controller I
> have added
>
> function beforeFilter() {
>         parent::beforeFilter();
>         $this->Auth->deny('addToWatchlist');
>
> }
>
> It should be very common and sometimesI think that maybe I am
> searching for the wrong topic. Can anyone give me an advice? Thanks so
> much.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: If not Ajax request

2009-05-20 Thread Dave Maharaj :: WidePixels.com

Thanks for the tip but I do not seem to follow you on 
"If yes, only addition of any random param to form action (or whatever you
request on "save" click) will save you."

The function has no form...pretty much just a quick save "bookmark". All the
saved data is gathered from the Auth id and the variable passed in the URL
link in the controller.

How would I implement the idea you mention?

Thanks,

Dave

-Original Message-
From: Dr. Loboto [mailto:drlob...@gmail.com] 
Sent: May-20-09 12:58 PM
To: CakePHP
Subject: Re: If not Ajax request


I almost can swear that you tested it in IE and after save no actual request
to server was done at all (can be checked in Apache access
logs) - you saw cached result of previous save call. If yes, only addition
of any random param to form action (or whatever you request on "save" click)
will save you.

On May 20, 9:28 pm, "Dave Maharaj :: WidePixels.com"
 wrote:
> I am trying to make sure the requested function is Ajax, if not 
> redirect...so if someone tries to manually enter it into the url it 
> redirects them back to the index page but not working the way i want.
> This is what happens:
> Scenario 1:
> original URL: localhost/testsite/journal/256 If someone goes to the 
> page, clicks save (save entry 256)...perfect...works.
> But if they then type in "entries/" into the url so it looks like
> localhost/testsite/journal/entries/256 it runs the Ajax function.
>
> Scenario 2
> If they go to the same page localhost/testsite/journal/256 and type in 
> "entries/" into the url so it looks like
> localhost/testsite/journal/entries/256  before saving an entry the 
> function re-directs as it should.
>
> Why is it only redirecting for scenario 2 and not 1?
>
> function entries($articles_id)
>       {
>
>           if ($this->RequestHandler->isAjax())
>         {
>
>             save entry code
>
>           }else{
>           //request is not AJAX
>           $this->redirect(array('controller' => 'journal', 'action' => 
> 'index'));
>         }
>       }
>
> Dave


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Auth. with an AJAX Request

2009-05-20 Thread Luke

Hi,

I have again read backwards and forwards through the www to find a
solution for my problem. I am sure that there is other people running
into the same issue. How do you guys solve it?

All I want is a link saying "Add article to watchlist" which than, if
the User is logged in writes it into the DB, Article gets shown again
and link changes to "In watchlist" and if User is not logged in
redirects to the Login Window with a message that you need to be
logged in to use this feature. All this should happen with AJAX. My
normal login is happening with Auth. and the typical stuff in the
beforeFilter() of the app_controller. In the watchlist controller I
have added

function beforeFilter() {
parent::beforeFilter();
$this->Auth->deny('addToWatchlist');
}

It should be very common and sometimesI think that maybe I am
searching for the wrong topic. Can anyone give me an advice? Thanks so
much.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: If not Ajax request

2009-05-20 Thread Dave Maharaj :: WidePixels.com

Almost got menot IE but Firefox... but yes I see the cached results of
the prior save. Will add params so if there are any then see what happens.

Thanks,

Dave 

-Original Message-
From: Dr. Loboto [mailto:drlob...@gmail.com] 
Sent: May-20-09 12:58 PM
To: CakePHP
Subject: Re: If not Ajax request


I almost can swear that you tested it in IE and after save no actual request
to server was done at all (can be checked in Apache access
logs) - you saw cached result of previous save call. If yes, only addition
of any random param to form action (or whatever you request on "save" click)
will save you.

On May 20, 9:28 pm, "Dave Maharaj :: WidePixels.com"
 wrote:
> I am trying to make sure the requested function is Ajax, if not 
> redirect...so if someone tries to manually enter it into the url it 
> redirects them back to the index page but not working the way i want.
> This is what happens:
> Scenario 1:
> original URL: localhost/testsite/journal/256 If someone goes to the 
> page, clicks save (save entry 256)...perfect...works.
> But if they then type in "entries/" into the url so it looks like
> localhost/testsite/journal/entries/256 it runs the Ajax function.
>
> Scenario 2
> If they go to the same page localhost/testsite/journal/256 and type in 
> "entries/" into the url so it looks like
> localhost/testsite/journal/entries/256  before saving an entry the 
> function re-directs as it should.
>
> Why is it only redirecting for scenario 2 and not 1?
>
> function entries($articles_id)
>       {
>
>           if ($this->RequestHandler->isAjax())
>         {
>
>             save entry code
>
>           }else{
>           //request is not AJAX
>           $this->redirect(array('controller' => 'journal', 'action' => 
> 'index'));
>         }
>       }
>
> Dave


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: If not Ajax request

2009-05-20 Thread Dr. Loboto

I almost can swear that you tested it in IE and after save no actual
request to server was done at all (can be checked in Apache access
logs) - you saw cached result of previous save call. If yes, only
addition of any random param to form action (or whatever you request
on "save" click) will save you.

On May 20, 9:28 pm, "Dave Maharaj :: WidePixels.com"
 wrote:
> I am trying to make sure the requested function is Ajax, if not
> redirect...so if someone tries to manually enter it into the url it
> redirects them back to the index page but not working the way i want.
> This is what happens:
> Scenario 1:
> original URL: localhost/testsite/journal/256
> If someone goes to the page, clicks save (save entry 256)...perfect...works.
> But if they then type in "entries/" into the url so it looks like
> localhost/testsite/journal/entries/256 it runs the Ajax function.
>
> Scenario 2
> If they go to the same page localhost/testsite/journal/256 and type in
> "entries/" into the url so it looks like
> localhost/testsite/journal/entries/256  before saving an entry the function
> re-directs as it should.
>
> Why is it only redirecting for scenario 2 and not 1?
>
> function entries($articles_id)
>       {
>
>           if ($this->RequestHandler->isAjax())
>         {
>
>             save entry code
>
>           }else{
>           //request is not AJAX
>           $this->redirect(array('controller' => 'journal', 'action' =>
> 'index'));
>         }
>       }
>
> Dave
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



If not Ajax request

2009-05-20 Thread Dave Maharaj :: WidePixels.com
I am trying to make sure the requested function is Ajax, if not
redirect...so if someone tries to manually enter it into the url it
redirects them back to the index page but not working the way i want.
This is what happens:
Scenario 1:
original URL: localhost/testsite/journal/256
If someone goes to the page, clicks save (save entry 256)...perfect...works.
But if they then type in "entries/" into the url so it looks like
localhost/testsite/journal/entries/256 it runs the Ajax function.
 
Scenario 2
If they go to the same page localhost/testsite/journal/256 and type in
"entries/" into the url so it looks like
localhost/testsite/journal/entries/256  before saving an entry the function
re-directs as it should.
 
Why is it only redirecting for scenario 2 and not 1?
 
function entries($articles_id)
  {

  if ($this->RequestHandler->isAjax()) 
{
 
save entry code

  }else{
  //request is not AJAX 
  $this->redirect(array('controller' => 'journal', 'action' =>
'index'));
}
  }
 
Dave 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Auth. with an AJAX Request

2009-05-19 Thread Luke

Hi brian,

thanks for your response. This is not really a solution I am looking
for. I think the link should still be visible all the time and I can't
imagine that cake and AJAX would not be able to handle this somehow. I
am sure that someone has faced a similar issue before and I am hoping
that they will share their solution. But thank you anyway.

Luke
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Auth. with an AJAX Request

2009-05-19 Thread brian

An AJAX request returns a chunk of HTML (or other data) and isn't
going to handle the redirect properly. The simplest way to deal with
this is to only display the link if the user is logged in.

On Tue, May 19, 2009 at 8:36 AM, Luke  wrote:
>
> Hi,
>
> I am still pretty new to CakePHP, so I am sorry if this is a silly
> issue I am dealing with. Ok, I am working on a site where you have
> different sections which require a Login.
>
> I therefore added the below Code into the app_controller
>
> var $components = array('Auth');
> var $helpers = array('Html','Form','Ajax','Javascript');
>
> function beforeFilter() {
>       $this->Auth->loginAction = array('controller' => 'users',
> 'action' => 'login');
>       $this->Auth->logoutRedirect = array('controller' => 'users',
> 'action' => 'login');
>       $this->Auth->allow('*');
>       $this->Auth->authorize = 'controller';
>       $this->Auth->userScope = array('User.confirmed' => '1');
>       $this->set('loggedIn', $this->Auth->user('id'));
>       $this->set('username', $this->Auth->user('username'));
> }
>
> function isAuthorized() {
>      return true;
> }
>
> So, all in all I allow all pages and than deny access to some
> functions which are than directly in the controller. I thought that
> this will be the easier way.
>
> I have now got a link to add a new article. In my controller I than
> have added this part:
>
>    function beforeFilter() {
>         parent::beforeFilter();
>         $this->Auth->deny('add');
>    }
>
> As I planned, if you are not logged in, the Login Window shows up and
> only when you logged in, the Form to add an article will show up.
>
> So all this works and I thought I now go a step further. You can add
> articles on your watchlist. Great, the article shows up, a link gets
> displayed on top of it "Add article to watchlist" this time I want to
> use an AJAX request.
>
> So I created the AJAX link
>
>  echo $ajax->link(Add article to watchlist',
>        array('controller' => mylist, 'action' =>'add', $articledetail
> ['Article']['id']),
>        array('update' => 'message',
>        ));
>
> and  added the below in my watchlist_controller
>
>  function beforeFilter() {
>        parent::beforeFilter();
>        $this->Auth->deny('add');
>  }
>
> So, what happens now? When you are not logged in, the article does not
> get add to your watchlist, but the Login Window does not show up.
> Instead you just still see the article not knowing if anything
> happened in the background.
>
> Of course I would like the Login Window to show up and when you are
> logged in the Article should be added to your watchlist, the article
> should show up again and the link should change to "Article in
> watchlist".
>
> Why is this not working with AJAX Link and how to I get it to work? I
> have read through the www, but can't find an answer. Maybe I am
> looking for the wrong topic... Can anyone here help?
>
> Look forward to some response. Thanks so much in advance.
>
> Luke
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



  1   2   >