Help with ajaxContext helper

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with ajaxContext helper

umpirsky
In init method of my controller I have

public function init() {
                $this->_helper->ajaxContext
                        ->setActionContext('facebook', 'html')
                        ->setActionContext('twitter', 'html')
                        ->initContext();
        }

This loads facebook and twitter widgets via ajax. They are in facebook.ajax.phtml and twitter.ajax.phtml and this works ok. But, very often I see in my error logs

2010-03-23T00:15:00+01:00 ERR (3): exception 'Zend_View_Exception' with message 'script 'index/facebook.phtml' not found in path (application/modules/default/views/scripts/)' in Zend/View/Abstract.php:976
Stack trace:
#0 Zend/View/Abstract.php(876): Zend_View_Abstract->_script('index/facebook....')
#1 Zend/Controller/Action/Helper/ViewRenderer.php(897): Zend_View_Abstract->render('index/facebook....')
#2 Zend/Controller/Action/Helper/ViewRenderer.php(918): Zend_Controller_Action_Helper_ViewRenderer->renderScript('index/facebook....', NULL)
#3 Zend/Controller/Action/Helper/ViewRenderer.php(957): Zend_Controller_Action_Helper_ViewRenderer->render()
#4 Zend/Controller/Action/HelperBroker.php(277): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#5 Zend/Controller/Action.php(523): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#6 Zend/Controller/Dispatcher/Standard.php(289): Zend_Controller_Action->dispatch('facebookAction')
#7 Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#8 Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#9 Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#10 public_html/index.php(24): Zend_Application->run()
#11 {main}

I assume that for some reason (may be disabled javascript or direct url visit) request goes not from ajax, but full page request without ajax headers and /format/html.

How can I fix to show just widget content, and skipp this error?
Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

Hector Virgen
The AjaxContext helper, in my opinion, is used to enhance an existing page with Ajax functionality. That means your page would be accessible normally without javascript, and then enhanced when javascript is available.

If your action is coded to be Ajax-only, and somehow a user requests that page without Ajax, then it seems proper that an error of some type should be thrown. You could create a new exception for this case, and throw it within your action if the page is requested without Ajax:

public function facebookAction()
{
    if (null === $this->_helper->ajaxContext->getContext()) {
        throw new AjaxRequiredException('Ajax is required to view this page');
    }
}

You could then test for this in your ErrorController and show a helpful error message to the user.

Another option would be to create a facebook.phtml file that shows the helpful error message.

--
Hector


On Tue, Mar 23, 2010 at 5:50 AM, umpirsky <[hidden email]> wrote:

In init method of my controller I have

public function init() {
               $this->_helper->ajaxContext
                       ->setActionContext('facebook', 'html')
                       ->setActionContext('twitter', 'html')
                       ->initContext();
       }

This loads facebook and twitter widgets via ajax. They are in
facebook.ajax.phtml and twitter.ajax.phtml and this works ok. But, very
often I see in my error logs

2010-03-23T00:15:00+01:00 ERR (3): exception 'Zend_View_Exception' with
message 'script 'index/facebook.phtml' not found in path
(application/modules/default/views/scripts/)' in Zend/View/Abstract.php:976
Stack trace:
#0 Zend/View/Abstract.php(876):
Zend_View_Abstract->_script('index/facebook....')
#1 Zend/Controller/Action/Helper/ViewRenderer.php(897):
Zend_View_Abstract->render('index/facebook....')
#2 Zend/Controller/Action/Helper/ViewRenderer.php(918):
Zend_Controller_Action_Helper_ViewRenderer->renderScript('index/facebook....',
NULL)
#3 Zend/Controller/Action/Helper/ViewRenderer.php(957):
Zend_Controller_Action_Helper_ViewRenderer->render()
#4 Zend/Controller/Action/HelperBroker.php(277):
Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#5 Zend/Controller/Action.php(523):
Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#6 Zend/Controller/Dispatcher/Standard.php(289):
Zend_Controller_Action->dispatch('facebookAction')
#7 Zend/Controller/Front.php(954):
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http),
Object(Zend_Controller_Response_Http))
#8 Zend/Application/Bootstrap/Bootstrap.php(97):
Zend_Controller_Front->dispatch()
#9 Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#10 public_html/index.php(24): Zend_Application->run()
#11 {main}

I assume that for some reason (may be disabled javascript or direct url
visit) request goes not from ajax, but full page request without ajax
headers and /format/html.

How can I fix to show just widget content, and skipp this error?
--
View this message in context: http://n4.nabble.com/Help-with-ajaxContext-helper-tp1679001p1679001.html
Sent from the Zend Framework mailing list archive at Nabble.com.

--
Hector Virgen
Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

umpirsky
Interesting. Is there a way to solve it on one place. What is enough for me is to prevent logging errors in error controller. 
So custom exception thrown from controller plugin is fine...if ajax action is called without ajax.

Regards,
Saša Stamenković


On Tue, Mar 23, 2010 at 5:43 PM, Hector Virgen <[hidden email]> wrote:
The AjaxContext helper, in my opinion, is used to enhance an existing page with Ajax functionality. That means your page would be accessible normally without javascript, and then enhanced when javascript is available.

If your action is coded to be Ajax-only, and somehow a user requests that page without Ajax, then it seems proper that an error of some type should be thrown. You could create a new exception for this case, and throw it within your action if the page is requested without Ajax:

public function facebookAction()
{
    if (null === $this->_helper->ajaxContext->getContext()) {
        throw new AjaxRequiredException('Ajax is required to view this page');
    }
}

You could then test for this in your ErrorController and show a helpful error message to the user.

Another option would be to create a facebook.phtml file that shows the helpful error message.

--
Hector


On Tue, Mar 23, 2010 at 5:50 AM, umpirsky <[hidden email]> wrote:

In init method of my controller I have

public function init() {
               $this->_helper->ajaxContext
                       ->setActionContext('facebook', 'html')
                       ->setActionContext('twitter', 'html')
                       ->initContext();
       }

This loads facebook and twitter widgets via ajax. They are in
facebook.ajax.phtml and twitter.ajax.phtml and this works ok. But, very
often I see in my error logs

2010-03-23T00:15:00+01:00 ERR (3): exception 'Zend_View_Exception' with
message 'script 'index/facebook.phtml' not found in path
(application/modules/default/views/scripts/)' in Zend/View/Abstract.php:976
Stack trace:
#0 Zend/View/Abstract.php(876):
Zend_View_Abstract->_script('index/facebook....')
#1 Zend/Controller/Action/Helper/ViewRenderer.php(897):
Zend_View_Abstract->render('index/facebook....')
#2 Zend/Controller/Action/Helper/ViewRenderer.php(918):
Zend_Controller_Action_Helper_ViewRenderer->renderScript('index/facebook....',
NULL)
#3 Zend/Controller/Action/Helper/ViewRenderer.php(957):
Zend_Controller_Action_Helper_ViewRenderer->render()
#4 Zend/Controller/Action/HelperBroker.php(277):
Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#5 Zend/Controller/Action.php(523):
Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#6 Zend/Controller/Dispatcher/Standard.php(289):
Zend_Controller_Action->dispatch('facebookAction')
#7 Zend/Controller/Front.php(954):
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http),
Object(Zend_Controller_Response_Http))
#8 Zend/Application/Bootstrap/Bootstrap.php(97):
Zend_Controller_Front->dispatch()
#9 Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#10 public_html/index.php(24): Zend_Application->run()
#11 {main}

I assume that for some reason (may be disabled javascript or direct url
visit) request goes not from ajax, but full page request without ajax
headers and /format/html.

How can I fix to show just widget content, and skipp this error?
--
View this message in context: http://n4.nabble.com/Help-with-ajaxContext-helper-tp1679001p1679001.html
Sent from the Zend Framework mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

umpirsky
I'm getting a number of logs daily. Very strange, it can't be that all of these people don't have javascript enabled.

Regards,
Saša Stamenković


On Tue, Mar 23, 2010 at 8:15 PM, Саша Стаменковић <[hidden email]> wrote:
Interesting. Is there a way to solve it on one place. What is enough for me is to prevent logging errors in error controller. 
So custom exception thrown from controller plugin is fine...if ajax action is called without ajax.

Regards,
Saša Stamenković



On Tue, Mar 23, 2010 at 5:43 PM, Hector Virgen <[hidden email]> wrote:
The AjaxContext helper, in my opinion, is used to enhance an existing page with Ajax functionality. That means your page would be accessible normally without javascript, and then enhanced when javascript is available.

If your action is coded to be Ajax-only, and somehow a user requests that page without Ajax, then it seems proper that an error of some type should be thrown. You could create a new exception for this case, and throw it within your action if the page is requested without Ajax:

public function facebookAction()
{
    if (null === $this->_helper->ajaxContext->getContext()) {
        throw new AjaxRequiredException('Ajax is required to view this page');
    }
}

You could then test for this in your ErrorController and show a helpful error message to the user.

Another option would be to create a facebook.phtml file that shows the helpful error message.

--
Hector


On Tue, Mar 23, 2010 at 5:50 AM, umpirsky <[hidden email]> wrote:

In init method of my controller I have

public function init() {
               $this->_helper->ajaxContext
                       ->setActionContext('facebook', 'html')
                       ->setActionContext('twitter', 'html')
                       ->initContext();
       }

This loads facebook and twitter widgets via ajax. They are in
facebook.ajax.phtml and twitter.ajax.phtml and this works ok. But, very
often I see in my error logs

2010-03-23T00:15:00+01:00 ERR (3): exception 'Zend_View_Exception' with
message 'script 'index/facebook.phtml' not found in path
(application/modules/default/views/scripts/)' in Zend/View/Abstract.php:976
Stack trace:
#0 Zend/View/Abstract.php(876):
Zend_View_Abstract->_script('index/facebook....')
#1 Zend/Controller/Action/Helper/ViewRenderer.php(897):
Zend_View_Abstract->render('index/facebook....')
#2 Zend/Controller/Action/Helper/ViewRenderer.php(918):
Zend_Controller_Action_Helper_ViewRenderer->renderScript('index/facebook....',
NULL)
#3 Zend/Controller/Action/Helper/ViewRenderer.php(957):
Zend_Controller_Action_Helper_ViewRenderer->render()
#4 Zend/Controller/Action/HelperBroker.php(277):
Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#5 Zend/Controller/Action.php(523):
Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#6 Zend/Controller/Dispatcher/Standard.php(289):
Zend_Controller_Action->dispatch('facebookAction')
#7 Zend/Controller/Front.php(954):
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http),
Object(Zend_Controller_Response_Http))
#8 Zend/Application/Bootstrap/Bootstrap.php(97):
Zend_Controller_Front->dispatch()
#9 Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#10 public_html/index.php(24): Zend_Application->run()
#11 {main}

I assume that for some reason (may be disabled javascript or direct url
visit) request goes not from ajax, but full page request without ajax
headers and /format/html.

How can I fix to show just widget content, and skipp this error?
--
View this message in context: http://n4.nabble.com/Help-with-ajaxContext-helper-tp1679001p1679001.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

Hector Virgen
Keep in mind that the AjaxContext helper needs two conditions to be satisfied in order for it to kick in:

  1. The header "X_REQUESTED_WITH" must be "XMLHttpRequest" (automatic with Prototype and jQuery) and
  2. The correct "format" parameter must be specified in the request,
It's that second requirement that tends to be the cause of most failed ajax requests in my own development (usually because I forget, or it wasn't sent properly in the Ajax request).

--
Hector


On Tue, Mar 23, 2010 at 11:57 PM, Саша Стаменковић <[hidden email]> wrote:
I'm getting a number of logs daily. Very strange, it can't be that all of these people don't have javascript enabled.

Regards,
Saša Stamenković



On Tue, Mar 23, 2010 at 8:15 PM, Саша Стаменковић <[hidden email]> wrote:
Interesting. Is there a way to solve it on one place. What is enough for me is to prevent logging errors in error controller. 
So custom exception thrown from controller plugin is fine...if ajax action is called without ajax.

Regards,
Saša Stamenković



On Tue, Mar 23, 2010 at 5:43 PM, Hector Virgen <[hidden email]> wrote:
The AjaxContext helper, in my opinion, is used to enhance an existing page with Ajax functionality. That means your page would be accessible normally without javascript, and then enhanced when javascript is available.

If your action is coded to be Ajax-only, and somehow a user requests that page without Ajax, then it seems proper that an error of some type should be thrown. You could create a new exception for this case, and throw it within your action if the page is requested without Ajax:

public function facebookAction()
{
    if (null === $this->_helper->ajaxContext->getContext()) {
        throw new AjaxRequiredException('Ajax is required to view this page');
    }
}

You could then test for this in your ErrorController and show a helpful error message to the user.

Another option would be to create a facebook.phtml file that shows the helpful error message.

--
Hector


On Tue, Mar 23, 2010 at 5:50 AM, umpirsky <[hidden email]> wrote:

In init method of my controller I have

public function init() {
               $this->_helper->ajaxContext
                       ->setActionContext('facebook', 'html')
                       ->setActionContext('twitter', 'html')
                       ->initContext();
       }

This loads facebook and twitter widgets via ajax. They are in
facebook.ajax.phtml and twitter.ajax.phtml and this works ok. But, very
often I see in my error logs

2010-03-23T00:15:00+01:00 ERR (3): exception 'Zend_View_Exception' with
message 'script 'index/facebook.phtml' not found in path
(application/modules/default/views/scripts/)' in Zend/View/Abstract.php:976
Stack trace:
#0 Zend/View/Abstract.php(876):
Zend_View_Abstract->_script('index/facebook....')
#1 Zend/Controller/Action/Helper/ViewRenderer.php(897):
Zend_View_Abstract->render('index/facebook....')
#2 Zend/Controller/Action/Helper/ViewRenderer.php(918):
Zend_Controller_Action_Helper_ViewRenderer->renderScript('index/facebook....',
NULL)
#3 Zend/Controller/Action/Helper/ViewRenderer.php(957):
Zend_Controller_Action_Helper_ViewRenderer->render()
#4 Zend/Controller/Action/HelperBroker.php(277):
Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#5 Zend/Controller/Action.php(523):
Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#6 Zend/Controller/Dispatcher/Standard.php(289):
Zend_Controller_Action->dispatch('facebookAction')
#7 Zend/Controller/Front.php(954):
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http),
Object(Zend_Controller_Response_Http))
#8 Zend/Application/Bootstrap/Bootstrap.php(97):
Zend_Controller_Front->dispatch()
#9 Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#10 public_html/index.php(24): Zend_Application->run()
#11 {main}

I assume that for some reason (may be disabled javascript or direct url
visit) request goes not from ajax, but full page request without ajax
headers and /format/html.

How can I fix to show just widget content, and skipp this error?
--
View this message in context: http://n4.nabble.com/Help-with-ajaxContext-helper-tp1679001p1679001.html
Sent from the Zend Framework mailing list archive at Nabble.com.




--
Hector Virgen
Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

Jurian Sluiman-4
In reply to this post by umpirsky
On Tuesday 23 Mar 2010 20:15:03 Саша Стаменковић wrote:
> Interesting. Is there a way to solve it on one place. What is enough for me
> is to prevent logging errors in error controller.
> So custom exception thrown from controller plugin is fine...if ajax action
> is called without ajax.
>
> Regards,
> Saša Stamenković

Solving the problem in one place means you need to extend the ajaxContext
action helper to check for specific non-Ajax requests.
--
Jurian Sluiman
CTO Soflomo V.O.F.
http://soflomo.com
Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

umpirsky
I thinks second requirement is there, but XMLHttpRequest is not. Otherwise, it would always fail.

Regards,
Saša Stamenković


On Wed, Mar 24, 2010 at 6:15 PM, Jurian Sluiman <[hidden email]> wrote:
On Tuesday 23 Mar 2010 20:15:03 Саша Стаменковић wrote:
> Interesting. Is there a way to solve it on one place. What is enough for me
> is to prevent logging errors in error controller.
> So custom exception thrown from controller plugin is fine...if ajax action
> is called without ajax.
>
> Regards,
> Saša Stamenković

Solving the problem in one place means you need to extend the ajaxContext
action helper to check for specific non-Ajax requests.
--
Jurian Sluiman
CTO Soflomo V.O.F.
http://soflomo.com

Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

A.J. Brown-3
Actually, I believe that ajaxContext does not use the "format" request
parameter.  Your problem is likely that the client is not sending the
proper headers.

Your best solution would be to use the contextSwitch helper instead,
and change your AJAX calls to pass the format parameter, or to throw
an exception when !$this->getRequest()->isXmlHttpRequest() for actions
that MUST be called via AJAX.  You might even want to put all of these
calls in their own controller, and throw the error to remain DRY.


On Thu, Mar 25, 2010 at 2:58 AM, Саша Стаменковић <[hidden email]> wrote:

> I thinks second requirement is there, but XMLHttpRequest is not. Otherwise,
> it would always fail.
>
> Regards,
> Saša Stamenković
>
>
> On Wed, Mar 24, 2010 at 6:15 PM, Jurian Sluiman <[hidden email]>
> wrote:
>>
>> On Tuesday 23 Mar 2010 20:15:03 Саша Стаменковић wrote:
>> > Interesting. Is there a way to solve it on one place. What is enough for
>> > me
>> > is to prevent logging errors in error controller.
>> > So custom exception thrown from controller plugin is fine...if ajax
>> > action
>> > is called without ajax.
>> >
>> > Regards,
>> > Saša Stamenković
>>
>> Solving the problem in one place means you need to extend the ajaxContext
>> action helper to check for specific non-Ajax requests.
>> --
>> Jurian Sluiman
>> CTO Soflomo V.O.F.
>> http://soflomo.com
>
>



--
A.J. Brown
Software Engineer, ZCE
blog : http://ajbrown.org
talk  : (937) 540-0099
chat : IntypicaAJ
Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

A.J. Brown-3
Correction: obviously ajaxContext does use the format parameter.  I'm
not sure what I was thinking :)


On Thu, Mar 25, 2010 at 11:06 AM, A.J. Brown <[hidden email]> wrote:

> Actually, I believe that ajaxContext does not use the "format" request
> parameter.  Your problem is likely that the client is not sending the
> proper headers.
>
> Your best solution would be to use the contextSwitch helper instead,
> and change your AJAX calls to pass the format parameter, or to throw
> an exception when !$this->getRequest()->isXmlHttpRequest() for actions
> that MUST be called via AJAX.  You might even want to put all of these
> calls in their own controller, and throw the error to remain DRY.
>
>
> On Thu, Mar 25, 2010 at 2:58 AM, Саша Стаменковић <[hidden email]> wrote:
>> I thinks second requirement is there, but XMLHttpRequest is not. Otherwise,
>> it would always fail.
>>
>> Regards,
>> Saša Stamenković
>>
>>
>> On Wed, Mar 24, 2010 at 6:15 PM, Jurian Sluiman <[hidden email]>
>> wrote:
>>>
>>> On Tuesday 23 Mar 2010 20:15:03 Саша Стаменковић wrote:
>>> > Interesting. Is there a way to solve it on one place. What is enough for
>>> > me
>>> > is to prevent logging errors in error controller.
>>> > So custom exception thrown from controller plugin is fine...if ajax
>>> > action
>>> > is called without ajax.
>>> >
>>> > Regards,
>>> > Saša Stamenković
>>>
>>> Solving the problem in one place means you need to extend the ajaxContext
>>> action helper to check for specific non-Ajax requests.
>>> --
>>> Jurian Sluiman
>>> CTO Soflomo V.O.F.
>>> http://soflomo.com
>>
>>
>
>
>
> --
> A.J. Brown
> Software Engineer, ZCE
> blog : http://ajbrown.org
> talk  : (937) 540-0099
> chat : IntypicaAJ
>



--
A.J. Brown
Software Engineer, ZCE
blog : http://ajbrown.org
talk  : (937) 540-0099
chat : IntypicaAJ
Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

scss
In reply to this post by A.J. Brown-3
In my case,
Since I did not take it as a  big problem, I did not investigate this
deeply but:
I use jquery and when i look at the headers send by jquery(with
firebug), xmlhttprequest param is set. But the context does not
change...




On Thu, Mar 25, 2010 at 5:06 PM, A.J. Brown <[hidden email]> wrote:

> Actually, I believe that ajaxContext does not use the "format" request
> parameter.  Your problem is likely that the client is not sending the
> proper headers.
>
> Your best solution would be to use the contextSwitch helper instead,
> and change your AJAX calls to pass the format parameter, or to throw
> an exception when !$this->getRequest()->isXmlHttpRequest() for actions
> that MUST be called via AJAX.  You might even want to put all of these
> calls in their own controller, and throw the error to remain DRY.
>
>
> On Thu, Mar 25, 2010 at 2:58 AM, Саша Стаменковић <[hidden email]> wrote:
>> I thinks second requirement is there, but XMLHttpRequest is not. Otherwise,
>> it would always fail.
>>
>> Regards,
>> Saša Stamenković
>>
>>
>> On Wed, Mar 24, 2010 at 6:15 PM, Jurian Sluiman <[hidden email]>
>> wrote:
>>>
>>> On Tuesday 23 Mar 2010 20:15:03 Саша Стаменковић wrote:
>>> > Interesting. Is there a way to solve it on one place. What is enough for
>>> > me
>>> > is to prevent logging errors in error controller.
>>> > So custom exception thrown from controller plugin is fine...if ajax
>>> > action
>>> > is called without ajax.
>>> >
>>> > Regards,
>>> > Saša Stamenković
>>>
>>> Solving the problem in one place means you need to extend the ajaxContext
>>> action helper to check for specific non-Ajax requests.
>>> --
>>> Jurian Sluiman
>>> CTO Soflomo V.O.F.
>>> http://soflomo.com
>>
>>
>
>
>
> --
> A.J. Brown
> Software Engineer, ZCE
> blog : http://ajbrown.org
> talk  : (937) 540-0099
> chat : IntypicaAJ
>
Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

umpirsky
In reply to this post by A.J. Brown-3
My ajax calls always send the format parameters.

Now I see that I have one json action, that is triggered ONLY from javascript, so no user will type /some/action/format/json in the location bar of the browser, but still I get

exception 'Zend_View_Exception' with message 'script 'some/action.phtml' not found in path...

Regards,
Saša Stamenković


On Thu, Mar 25, 2010 at 4:09 PM, A.J. Brown <[hidden email]> wrote:
Correction: obviously ajaxContext does use the format parameter.  I'm
not sure what I was thinking :)


On Thu, Mar 25, 2010 at 11:06 AM, A.J. Brown <[hidden email]> wrote:
> Actually, I believe that ajaxContext does not use the "format" request
> parameter.  Your problem is likely that the client is not sending the
> proper headers.
>
> Your best solution would be to use the contextSwitch helper instead,
> and change your AJAX calls to pass the format parameter, or to throw
> an exception when !$this->getRequest()->isXmlHttpRequest() for actions
> that MUST be called via AJAX.  You might even want to put all of these
> calls in their own controller, and throw the error to remain DRY.
>
>
> On Thu, Mar 25, 2010 at 2:58 AM, Саша Стаменковић <[hidden email]> wrote:
>> I thinks second requirement is there, but XMLHttpRequest is not. Otherwise,
>> it would always fail.
>>
>> Regards,
>> Saša Stamenković
>>
>>
>> On Wed, Mar 24, 2010 at 6:15 PM, Jurian Sluiman <[hidden email]>
>> wrote:
>>>
>>> On Tuesday 23 Mar 2010 20:15:03 Саша Стаменковић wrote:
>>> > Interesting. Is there a way to solve it on one place. What is enough for
>>> > me
>>> > is to prevent logging errors in error controller.
>>> > So custom exception thrown from controller plugin is fine...if ajax
>>> > action
>>> > is called without ajax.
>>> >
>>> > Regards,
>>> > Saša Stamenković
>>>
>>> Solving the problem in one place means you need to extend the ajaxContext
>>> action helper to check for specific non-Ajax requests.
>>> --
>>> Jurian Sluiman
>>> CTO Soflomo V.O.F.
>>> http://soflomo.com
>>
>>
>
>
>
> --
> A.J. Brown
> Software Engineer, ZCE
> blog : http://ajbrown.org
> talk  : (937) 540-0099
> chat : IntypicaAJ
>



--
A.J. Brown
Software Engineer, ZCE
blog : http://ajbrown.org
talk  : (937) 540-0099
chat : IntypicaAJ

Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

Hector Virgen
Are you manually calling $this->render() in your action, or do you have a controller plugin or helper that is calling it?

--
Hector


On Thu, Mar 25, 2010 at 8:12 AM, Саша Стаменковић <[hidden email]> wrote:
My ajax calls always send the format parameters.

Now I see that I have one json action, that is triggered ONLY from javascript, so no user will type /some/action/format/json in the location bar of the browser, but still I get

exception 'Zend_View_Exception' with message 'script 'some/action.phtml' not found in path...

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 4:09 PM, A.J. Brown <[hidden email]> wrote:
Correction: obviously ajaxContext does use the format parameter.  I'm
not sure what I was thinking :)


On Thu, Mar 25, 2010 at 11:06 AM, A.J. Brown <[hidden email]> wrote:
> Actually, I believe that ajaxContext does not use the "format" request
> parameter.  Your problem is likely that the client is not sending the
> proper headers.
>
> Your best solution would be to use the contextSwitch helper instead,
> and change your AJAX calls to pass the format parameter, or to throw
> an exception when !$this->getRequest()->isXmlHttpRequest() for actions
> that MUST be called via AJAX.  You might even want to put all of these
> calls in their own controller, and throw the error to remain DRY.
>
>
> On Thu, Mar 25, 2010 at 2:58 AM, Саша Стаменковић <[hidden email]> wrote:
>> I thinks second requirement is there, but XMLHttpRequest is not. Otherwise,
>> it would always fail.
>>
>> Regards,
>> Saša Stamenković
>>
>>
>> On Wed, Mar 24, 2010 at 6:15 PM, Jurian Sluiman <[hidden email]>
>> wrote:
>>>
>>> On Tuesday 23 Mar 2010 20:15:03 Саша Стаменковић wrote:
>>> > Interesting. Is there a way to solve it on one place. What is enough for
>>> > me
>>> > is to prevent logging errors in error controller.
>>> > So custom exception thrown from controller plugin is fine...if ajax
>>> > action
>>> > is called without ajax.
>>> >
>>> > Regards,
>>> > Saša Stamenković
>>>
>>> Solving the problem in one place means you need to extend the ajaxContext
>>> action helper to check for specific non-Ajax requests.
>>> --
>>> Jurian Sluiman
>>> CTO Soflomo V.O.F.
>>> http://soflomo.com
>>
>>
>
>
>
> --
> A.J. Brown
> Software Engineer, ZCE
> blog : http://ajbrown.org
> talk  : (937) 540-0099
> chat : IntypicaAJ
>



--
A.J. Brown
Software Engineer, ZCE
blog : http://ajbrown.org
talk  : (937) 540-0099
chat : IntypicaAJ


--
Hector Virgen
Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

umpirsky
<?php
class PretragaController extends Zend_Controller_Action {


public function init() {
$this->_helper->ajaxContext
->setActionContext('uzmi-modele', 'html')
->setActionContext('oglasi-broj', 'json')
->setActionContext('kontakt', 'html')
->initContext();
}

//....

  public function oglasiBrojAction() {
     $car = new Automobili_Model_Table_Car();
        $form = new Automobili_Form_QuickSearch();
     $form->populate($this->_getAllParams());

     $this->view->count = $car->searchCount($form);
    }

}

Everithing is done via helper, but for some reason, sometimes, insted looking for 'pretraga/oglasi-broj.ajax.phtml' it looks for 'pretraga/oglasi-broj.phtml'. This can be reproduced with visiting action directly without ajax.

For me this is the problem since all I get whole day is errors like this. I really want to know the reason, why this happends.

Regards,
Saša Stamenković


On Thu, Mar 25, 2010 at 4:14 PM, Hector Virgen <[hidden email]> wrote:
Are you manually calling $this->render() in your action, or do you have a controller plugin or helper that is calling it?

--
Hector



On Thu, Mar 25, 2010 at 8:12 AM, Саша Стаменковић <[hidden email]> wrote:
My ajax calls always send the format parameters.

Now I see that I have one json action, that is triggered ONLY from javascript, so no user will type /some/action/format/json in the location bar of the browser, but still I get

exception 'Zend_View_Exception' with message 'script 'some/action.phtml' not found in path...

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 4:09 PM, A.J. Brown <[hidden email]> wrote:
Correction: obviously ajaxContext does use the format parameter.  I'm
not sure what I was thinking :)


On Thu, Mar 25, 2010 at 11:06 AM, A.J. Brown <[hidden email]> wrote:
> Actually, I believe that ajaxContext does not use the "format" request
> parameter.  Your problem is likely that the client is not sending the
> proper headers.
>
> Your best solution would be to use the contextSwitch helper instead,
> and change your AJAX calls to pass the format parameter, or to throw
> an exception when !$this->getRequest()->isXmlHttpRequest() for actions
> that MUST be called via AJAX.  You might even want to put all of these
> calls in their own controller, and throw the error to remain DRY.
>
>
> On Thu, Mar 25, 2010 at 2:58 AM, Саша Стаменковић <[hidden email]> wrote:
>> I thinks second requirement is there, but XMLHttpRequest is not. Otherwise,
>> it would always fail.
>>
>> Regards,
>> Saša Stamenković
>>
>>
>> On Wed, Mar 24, 2010 at 6:15 PM, Jurian Sluiman <[hidden email]>
>> wrote:
>>>
>>> On Tuesday 23 Mar 2010 20:15:03 Саша Стаменковић wrote:
>>> > Interesting. Is there a way to solve it on one place. What is enough for
>>> > me
>>> > is to prevent logging errors in error controller.
>>> > So custom exception thrown from controller plugin is fine...if ajax
>>> > action
>>> > is called without ajax.
>>> >
>>> > Regards,
>>> > Saša Stamenković
>>>
>>> Solving the problem in one place means you need to extend the ajaxContext
>>> action helper to check for specific non-Ajax requests.
>>> --
>>> Jurian Sluiman
>>> CTO Soflomo V.O.F.
>>> http://soflomo.com
>>
>>
>
>
>
> --
> A.J. Brown
> Software Engineer, ZCE
> blog : http://ajbrown.org
> talk  : (937) 540-0099
> chat : IntypicaAJ
>



--
A.J. Brown
Software Engineer, ZCE
blog : http://ajbrown.org
talk  : (937) 540-0099
chat : IntypicaAJ



Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

Hector Virgen
That seems fine to me, but there may be something else creating a request for that action without ajax. Can you add some logging in your action to log the request? It might give you some details as to what's happening when it errors.

--
Hector


On Thu, Mar 25, 2010 at 8:18 AM, Саша Стаменковић <[hidden email]> wrote:
<?php
class PretragaController extends Zend_Controller_Action {


public function init() {
$this->_helper->ajaxContext
->setActionContext('uzmi-modele', 'html')
->setActionContext('oglasi-broj', 'json')
->setActionContext('kontakt', 'html')
->initContext();
}

//....

  public function oglasiBrojAction() {
     $car = new Automobili_Model_Table_Car();
        $form = new Automobili_Form_QuickSearch();
     $form->populate($this->_getAllParams());

     $this->view->count = $car->searchCount($form);
    }

}

Everithing is done via helper, but for some reason, sometimes, insted looking for 'pretraga/oglasi-broj.ajax.phtml' it looks for 'pretraga/oglasi-broj.phtml'. This can be reproduced with visiting action directly without ajax.

For me this is the problem since all I get whole day is errors like this. I really want to know the reason, why this happends.

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 4:14 PM, Hector Virgen <[hidden email]> wrote:
Are you manually calling $this->render() in your action, or do you have a controller plugin or helper that is calling it?

--
Hector



On Thu, Mar 25, 2010 at 8:12 AM, Саша Стаменковић <[hidden email]> wrote:
My ajax calls always send the format parameters.

Now I see that I have one json action, that is triggered ONLY from javascript, so no user will type /some/action/format/json in the location bar of the browser, but still I get

exception 'Zend_View_Exception' with message 'script 'some/action.phtml' not found in path...

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 4:09 PM, A.J. Brown <[hidden email]> wrote:
Correction: obviously ajaxContext does use the format parameter.  I'm
not sure what I was thinking :)


On Thu, Mar 25, 2010 at 11:06 AM, A.J. Brown <[hidden email]> wrote:
> Actually, I believe that ajaxContext does not use the "format" request
> parameter.  Your problem is likely that the client is not sending the
> proper headers.
>
> Your best solution would be to use the contextSwitch helper instead,
> and change your AJAX calls to pass the format parameter, or to throw
> an exception when !$this->getRequest()->isXmlHttpRequest() for actions
> that MUST be called via AJAX.  You might even want to put all of these
> calls in their own controller, and throw the error to remain DRY.
>
>
> On Thu, Mar 25, 2010 at 2:58 AM, Саша Стаменковић <[hidden email]> wrote:
>> I thinks second requirement is there, but XMLHttpRequest is not. Otherwise,
>> it would always fail.
>>
>> Regards,
>> Saša Stamenković
>>
>>
>> On Wed, Mar 24, 2010 at 6:15 PM, Jurian Sluiman <[hidden email]>
>> wrote:
>>>
>>> On Tuesday 23 Mar 2010 20:15:03 Саша Стаменковић wrote:
>>> > Interesting. Is there a way to solve it on one place. What is enough for
>>> > me
>>> > is to prevent logging errors in error controller.
>>> > So custom exception thrown from controller plugin is fine...if ajax
>>> > action
>>> > is called without ajax.
>>> >
>>> > Regards,
>>> > Saša Stamenković
>>>
>>> Solving the problem in one place means you need to extend the ajaxContext
>>> action helper to check for specific non-Ajax requests.
>>> --
>>> Jurian Sluiman
>>> CTO Soflomo V.O.F.
>>> http://soflomo.com
>>
>>
>
>
>
> --
> A.J. Brown
> Software Engineer, ZCE
> blog : http://ajbrown.org
> talk  : (937) 540-0099
> chat : IntypicaAJ
>



--
A.J. Brown
Software Engineer, ZCE
blog : http://ajbrown.org
talk  : (937) 540-0099
chat : IntypicaAJ




--
Hector Virgen
Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

umpirsky
Will do, stay tunes ;)

Regards,
Saša Stamenković


On Thu, Mar 25, 2010 at 4:25 PM, Hector Virgen <[hidden email]> wrote:
That seems fine to me, but there may be something else creating a request for that action without ajax. Can you add some logging in your action to log the request? It might give you some details as to what's happening when it errors.

--
Hector



On Thu, Mar 25, 2010 at 8:18 AM, Саша Стаменковић <[hidden email]> wrote:
<?php
class PretragaController extends Zend_Controller_Action {


public function init() {
$this->_helper->ajaxContext
->setActionContext('uzmi-modele', 'html')
->setActionContext('oglasi-broj', 'json')
->setActionContext('kontakt', 'html')
->initContext();
}

//....

  public function oglasiBrojAction() {
     $car = new Automobili_Model_Table_Car();
        $form = new Automobili_Form_QuickSearch();
     $form->populate($this->_getAllParams());

     $this->view->count = $car->searchCount($form);
    }

}

Everithing is done via helper, but for some reason, sometimes, insted looking for 'pretraga/oglasi-broj.ajax.phtml' it looks for 'pretraga/oglasi-broj.phtml'. This can be reproduced with visiting action directly without ajax.

For me this is the problem since all I get whole day is errors like this. I really want to know the reason, why this happends.

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 4:14 PM, Hector Virgen <[hidden email]> wrote:
Are you manually calling $this->render() in your action, or do you have a controller plugin or helper that is calling it?

--
Hector



On Thu, Mar 25, 2010 at 8:12 AM, Саша Стаменковић <[hidden email]> wrote:
My ajax calls always send the format parameters.

Now I see that I have one json action, that is triggered ONLY from javascript, so no user will type /some/action/format/json in the location bar of the browser, but still I get

exception 'Zend_View_Exception' with message 'script 'some/action.phtml' not found in path...

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 4:09 PM, A.J. Brown <[hidden email]> wrote:
Correction: obviously ajaxContext does use the format parameter.  I'm
not sure what I was thinking :)


On Thu, Mar 25, 2010 at 11:06 AM, A.J. Brown <[hidden email]> wrote:
> Actually, I believe that ajaxContext does not use the "format" request
> parameter.  Your problem is likely that the client is not sending the
> proper headers.
>
> Your best solution would be to use the contextSwitch helper instead,
> and change your AJAX calls to pass the format parameter, or to throw
> an exception when !$this->getRequest()->isXmlHttpRequest() for actions
> that MUST be called via AJAX.  You might even want to put all of these
> calls in their own controller, and throw the error to remain DRY.
>
>
> On Thu, Mar 25, 2010 at 2:58 AM, Саша Стаменковић <[hidden email]> wrote:
>> I thinks second requirement is there, but XMLHttpRequest is not. Otherwise,
>> it would always fail.
>>
>> Regards,
>> Saša Stamenković
>>
>>
>> On Wed, Mar 24, 2010 at 6:15 PM, Jurian Sluiman <[hidden email]>
>> wrote:
>>>
>>> On Tuesday 23 Mar 2010 20:15:03 Саша Стаменковић wrote:
>>> > Interesting. Is there a way to solve it on one place. What is enough for
>>> > me
>>> > is to prevent logging errors in error controller.
>>> > So custom exception thrown from controller plugin is fine...if ajax
>>> > action
>>> > is called without ajax.
>>> >
>>> > Regards,
>>> > Saša Stamenković
>>>
>>> Solving the problem in one place means you need to extend the ajaxContext
>>> action helper to check for specific non-Ajax requests.
>>> --
>>> Jurian Sluiman
>>> CTO Soflomo V.O.F.
>>> http://soflomo.com
>>
>>
>
>
>
> --
> A.J. Brown
> Software Engineer, ZCE
> blog : http://ajbrown.org
> talk  : (937) 540-0099
> chat : IntypicaAJ
>



--
A.J. Brown
Software Engineer, ZCE
blog : http://ajbrown.org
talk  : (937) 540-0099
chat : IntypicaAJ





Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

umpirsky
Looks like it's googlebot  

'HTTP_FROM' => 'googlebot(at)googlebot.com'

:)

Ok, he found on home pagehttp://automobi.li/ this link /index/facebook/format/html

waiting to see who is accessing the link which is only and only in my javascript...and looking for the solution for preventing this errors to be placed in error.log, ah maybe robots.txt.

Regards,
Saša Stamenković


On Thu, Mar 25, 2010 at 8:57 PM, Саша Стаменковић <[hidden email]> wrote:
Will do, stay tunes ;)

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 4:25 PM, Hector Virgen <[hidden email]> wrote:
That seems fine to me, but there may be something else creating a request for that action without ajax. Can you add some logging in your action to log the request? It might give you some details as to what's happening when it errors.

--
Hector



On Thu, Mar 25, 2010 at 8:18 AM, Саша Стаменковић <[hidden email]> wrote:
<?php
class PretragaController extends Zend_Controller_Action {


public function init() {
$this->_helper->ajaxContext
->setActionContext('uzmi-modele', 'html')
->setActionContext('oglasi-broj', 'json')
->setActionContext('kontakt', 'html')
->initContext();
}

//....

  public function oglasiBrojAction() {
     $car = new Automobili_Model_Table_Car();
        $form = new Automobili_Form_QuickSearch();
     $form->populate($this->_getAllParams());

     $this->view->count = $car->searchCount($form);
    }

}

Everithing is done via helper, but for some reason, sometimes, insted looking for 'pretraga/oglasi-broj.ajax.phtml' it looks for 'pretraga/oglasi-broj.phtml'. This can be reproduced with visiting action directly without ajax.

For me this is the problem since all I get whole day is errors like this. I really want to know the reason, why this happends.

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 4:14 PM, Hector Virgen <[hidden email]> wrote:
Are you manually calling $this->render() in your action, or do you have a controller plugin or helper that is calling it?

--
Hector



On Thu, Mar 25, 2010 at 8:12 AM, Саша Стаменковић <[hidden email]> wrote:
My ajax calls always send the format parameters.

Now I see that I have one json action, that is triggered ONLY from javascript, so no user will type /some/action/format/json in the location bar of the browser, but still I get

exception 'Zend_View_Exception' with message 'script 'some/action.phtml' not found in path...

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 4:09 PM, A.J. Brown <[hidden email]> wrote:
Correction: obviously ajaxContext does use the format parameter.  I'm
not sure what I was thinking :)


On Thu, Mar 25, 2010 at 11:06 AM, A.J. Brown <[hidden email]> wrote:
> Actually, I believe that ajaxContext does not use the "format" request
> parameter.  Your problem is likely that the client is not sending the
> proper headers.
>
> Your best solution would be to use the contextSwitch helper instead,
> and change your AJAX calls to pass the format parameter, or to throw
> an exception when !$this->getRequest()->isXmlHttpRequest() for actions
> that MUST be called via AJAX.  You might even want to put all of these
> calls in their own controller, and throw the error to remain DRY.
>
>
> On Thu, Mar 25, 2010 at 2:58 AM, Саша Стаменковић <[hidden email]> wrote:
>> I thinks second requirement is there, but XMLHttpRequest is not. Otherwise,
>> it would always fail.
>>
>> Regards,
>> Saša Stamenković
>>
>>
>> On Wed, Mar 24, 2010 at 6:15 PM, Jurian Sluiman <[hidden email]>
>> wrote:
>>>
>>> On Tuesday 23 Mar 2010 20:15:03 Саша Стаменковић wrote:
>>> > Interesting. Is there a way to solve it on one place. What is enough for
>>> > me
>>> > is to prevent logging errors in error controller.
>>> > So custom exception thrown from controller plugin is fine...if ajax
>>> > action
>>> > is called without ajax.
>>> >
>>> > Regards,
>>> > Saša Stamenković
>>>
>>> Solving the problem in one place means you need to extend the ajaxContext
>>> action helper to check for specific non-Ajax requests.
>>> --
>>> Jurian Sluiman
>>> CTO Soflomo V.O.F.
>>> http://soflomo.com
>>
>>
>
>
>
> --
> A.J. Brown
> Software Engineer, ZCE
> blog : http://ajbrown.org
> talk  : (937) 540-0099
> chat : IntypicaAJ
>



--
A.J. Brown
Software Engineer, ZCE
blog : http://ajbrown.org
talk  : (937) 540-0099
chat : IntypicaAJ






Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

Hector Virgen
Nice find! :)

--
Hector


On Fri, Mar 26, 2010 at 4:29 AM, Саша Стаменковић <[hidden email]> wrote:
Looks like it's googlebot  

'HTTP_FROM' => 'googlebot(at)googlebot.com'

:)

Ok, he found on home pagehttp://automobi.li/ this link /index/facebook/format/html

waiting to see who is accessing the link which is only and only in my javascript...and looking for the solution for preventing this errors to be placed in error.log, ah maybe robots.txt.

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 8:57 PM, Саша Стаменковић <[hidden email]> wrote:
Will do, stay tunes ;)

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 4:25 PM, Hector Virgen <[hidden email]> wrote:
That seems fine to me, but there may be something else creating a request for that action without ajax. Can you add some logging in your action to log the request? It might give you some details as to what's happening when it errors.

--
Hector



On Thu, Mar 25, 2010 at 8:18 AM, Саша Стаменковић <[hidden email]> wrote:
<?php
class PretragaController extends Zend_Controller_Action {


public function init() {
$this->_helper->ajaxContext
->setActionContext('uzmi-modele', 'html')
->setActionContext('oglasi-broj', 'json')
->setActionContext('kontakt', 'html')
->initContext();
}

//....

  public function oglasiBrojAction() {
     $car = new Automobili_Model_Table_Car();
        $form = new Automobili_Form_QuickSearch();
     $form->populate($this->_getAllParams());

     $this->view->count = $car->searchCount($form);
    }

}

Everithing is done via helper, but for some reason, sometimes, insted looking for 'pretraga/oglasi-broj.ajax.phtml' it looks for 'pretraga/oglasi-broj.phtml'. This can be reproduced with visiting action directly without ajax.

For me this is the problem since all I get whole day is errors like this. I really want to know the reason, why this happends.

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 4:14 PM, Hector Virgen <[hidden email]> wrote:
Are you manually calling $this->render() in your action, or do you have a controller plugin or helper that is calling it?

--
Hector



On Thu, Mar 25, 2010 at 8:12 AM, Саша Стаменковић <[hidden email]> wrote:
My ajax calls always send the format parameters.

Now I see that I have one json action, that is triggered ONLY from javascript, so no user will type /some/action/format/json in the location bar of the browser, but still I get

exception 'Zend_View_Exception' with message 'script 'some/action.phtml' not found in path...

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 4:09 PM, A.J. Brown <[hidden email]> wrote:
Correction: obviously ajaxContext does use the format parameter.  I'm
not sure what I was thinking :)


On Thu, Mar 25, 2010 at 11:06 AM, A.J. Brown <[hidden email]> wrote:
> Actually, I believe that ajaxContext does not use the "format" request
> parameter.  Your problem is likely that the client is not sending the
> proper headers.
>
> Your best solution would be to use the contextSwitch helper instead,
> and change your AJAX calls to pass the format parameter, or to throw
> an exception when !$this->getRequest()->isXmlHttpRequest() for actions
> that MUST be called via AJAX.  You might even want to put all of these
> calls in their own controller, and throw the error to remain DRY.
>
>
> On Thu, Mar 25, 2010 at 2:58 AM, Саша Стаменковић <[hidden email]> wrote:
>> I thinks second requirement is there, but XMLHttpRequest is not. Otherwise,
>> it would always fail.
>>
>> Regards,
>> Saša Stamenković
>>
>>
>> On Wed, Mar 24, 2010 at 6:15 PM, Jurian Sluiman <[hidden email]>
>> wrote:
>>>
>>> On Tuesday 23 Mar 2010 20:15:03 Саша Стаменковић wrote:
>>> > Interesting. Is there a way to solve it on one place. What is enough for
>>> > me
>>> > is to prevent logging errors in error controller.
>>> > So custom exception thrown from controller plugin is fine...if ajax
>>> > action
>>> > is called without ajax.
>>> >
>>> > Regards,
>>> > Saša Stamenković
>>>
>>> Solving the problem in one place means you need to extend the ajaxContext
>>> action helper to check for specific non-Ajax requests.
>>> --
>>> Jurian Sluiman
>>> CTO Soflomo V.O.F.
>>> http://soflomo.com
>>
>>
>
>
>
> --
> A.J. Brown
> Software Engineer, ZCE
> blog : http://ajbrown.org
> talk  : (937) 540-0099
> chat : IntypicaAJ
>



--
A.J. Brown
Software Engineer, ZCE
blog : http://ajbrown.org
talk  : (937) 540-0099
chat : IntypicaAJ







--
Hector Virgen
Reply | Threaded
Open this post in threaded view
|

Re: Help with ajaxContext helper

umpirsky
Oh, 

'HTTP_USER_AGENT' => 'Mozilla/5.0 (compatible; Purebot/1.1; +http://www.puritysearch.net/)'

is killing it too.


'REQUEST_URI' is '/index/facebook/format/html'

even if I put

User-agent: *
Disallow: /index/twitter/format/html
Allow: /
Disallow: /index/facebook/format/html

in robots.txt

Regards,
Saša Stamenković


On Fri, Mar 26, 2010 at 4:13 PM, Hector Virgen <[hidden email]> wrote:
Nice find! :)

--
Hector



On Fri, Mar 26, 2010 at 4:29 AM, Саша Стаменковић <[hidden email]> wrote:
Looks like it's googlebot  

'HTTP_FROM' => 'googlebot(at)googlebot.com'

:)

Ok, he found on home pagehttp://automobi.li/ this link /index/facebook/format/html

waiting to see who is accessing the link which is only and only in my javascript...and looking for the solution for preventing this errors to be placed in error.log, ah maybe robots.txt.

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 8:57 PM, Саша Стаменковић <[hidden email]> wrote:
Will do, stay tunes ;)

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 4:25 PM, Hector Virgen <[hidden email]> wrote:
That seems fine to me, but there may be something else creating a request for that action without ajax. Can you add some logging in your action to log the request? It might give you some details as to what's happening when it errors.

--
Hector



On Thu, Mar 25, 2010 at 8:18 AM, Саша Стаменковић <[hidden email]> wrote:
<?php
class PretragaController extends Zend_Controller_Action {


public function init() {
$this->_helper->ajaxContext
->setActionContext('uzmi-modele', 'html')
->setActionContext('oglasi-broj', 'json')
->setActionContext('kontakt', 'html')
->initContext();
}

//....

  public function oglasiBrojAction() {
     $car = new Automobili_Model_Table_Car();
        $form = new Automobili_Form_QuickSearch();
     $form->populate($this->_getAllParams());

     $this->view->count = $car->searchCount($form);
    }

}

Everithing is done via helper, but for some reason, sometimes, insted looking for 'pretraga/oglasi-broj.ajax.phtml' it looks for 'pretraga/oglasi-broj.phtml'. This can be reproduced with visiting action directly without ajax.

For me this is the problem since all I get whole day is errors like this. I really want to know the reason, why this happends.

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 4:14 PM, Hector Virgen <[hidden email]> wrote:
Are you manually calling $this->render() in your action, or do you have a controller plugin or helper that is calling it?

--
Hector



On Thu, Mar 25, 2010 at 8:12 AM, Саша Стаменковић <[hidden email]> wrote:
My ajax calls always send the format parameters.

Now I see that I have one json action, that is triggered ONLY from javascript, so no user will type /some/action/format/json in the location bar of the browser, but still I get

exception 'Zend_View_Exception' with message 'script 'some/action.phtml' not found in path...

Regards,
Saša Stamenković



On Thu, Mar 25, 2010 at 4:09 PM, A.J. Brown <[hidden email]> wrote:
Correction: obviously ajaxContext does use the format parameter.  I'm
not sure what I was thinking :)


On Thu, Mar 25, 2010 at 11:06 AM, A.J. Brown <[hidden email]> wrote:
> Actually, I believe that ajaxContext does not use the "format" request
> parameter.  Your problem is likely that the client is not sending the
> proper headers.
>
> Your best solution would be to use the contextSwitch helper instead,
> and change your AJAX calls to pass the format parameter, or to throw
> an exception when !$this->getRequest()->isXmlHttpRequest() for actions
> that MUST be called via AJAX.  You might even want to put all of these
> calls in their own controller, and throw the error to remain DRY.
>
>
> On Thu, Mar 25, 2010 at 2:58 AM, Саша Стаменковић <[hidden email]> wrote:
>> I thinks second requirement is there, but XMLHttpRequest is not. Otherwise,
>> it would always fail.
>>
>> Regards,
>> Saša Stamenković
>>
>>
>> On Wed, Mar 24, 2010 at 6:15 PM, Jurian Sluiman <[hidden email]>
>> wrote:
>>>
>>> On Tuesday 23 Mar 2010 20:15:03 Саша Стаменковић wrote:
>>> > Interesting. Is there a way to solve it on one place. What is enough for
>>> > me
>>> > is to prevent logging errors in error controller.
>>> > So custom exception thrown from controller plugin is fine...if ajax
>>> > action
>>> > is called without ajax.
>>> >
>>> > Regards,
>>> > Saša Stamenković
>>>
>>> Solving the problem in one place means you need to extend the ajaxContext
>>> action helper to check for specific non-Ajax requests.
>>> --
>>> Jurian Sluiman
>>> CTO Soflomo V.O.F.
>>> http://soflomo.com
>>
>>
>
>
>
> --
> A.J. Brown
> Software Engineer, ZCE
> blog : http://ajbrown.org
> talk  : (937) 540-0099
> chat : IntypicaAJ
>



--
A.J. Brown
Software Engineer, ZCE
blog : http://ajbrown.org
talk  : (937) 540-0099
chat : IntypicaAJ