phpdevshell team mailing list archive
-
phpdevshell team
-
Mailing list archive
-
Message #00726
[Bug 934297] Re: Ajax and JSON request problems
** Changed in: phpdevshell
Status: Confirmed => Fix Committed
--
You received this bug notification because you are a member of
PHPDevShell, which is subscribed to PHPDevShell.
https://bugs.launchpad.net/bugs/934297
Title:
Ajax and JSON request problems
Status in Open Source PHP RAD Framework with UI.:
Fix Committed
Bug description:
PHPDevShell version 3.0.1 and 3.0.3.
The Ajax menu type (10) currently always assume that HTML will be returned from the server when it may also be XML or JSON. It also by default injects some LightBox script into its results which obviously breaks any XML or JSON results. The Lightbox html looks like this:
<script type="text/javascript">PHPDS_documentReady('#PHPDS_lightbox');</script> <!-- LIGHTBOX -->
<div id="PHPDS_lightbox">[JSON RESULT or XML RESULT]</div>
Currently the only way to get around this problem is to configure the
menu as a Standard menu (1 - Standard Web Page) and to set its Theme
to empty. Then lastly one have to also add the header
"application/json" using: header("Content-Type: application/json"); in
your controller.
I have two suggestions:
Suggestion A) Add two more menu types namely Ajax XML and JSON and let it behave in the correct way.
Suggestion B) Change the Ajax menu to read an additional parameter or
request header to determine the output result. For example, one should
be able to either add a URL parameter such as datatype=ajax /
datatype=json or perhaps even better the "Accept:" request header
should be adhered to. For example a standard JQuery JSON request
header looks like this: "Accept: application/json text/javascript" and
PHPDevshell can pick up on this to know how to respond to the request.
I personally do not like the fact that one has to pass a URL parameter
through to let PHPDevShell know what it is dealing with. If one
forgets to add ajax=true to the Ajax request URL the server returns
with an invalid or empty response which buggers the handling on the
Javascript side. This is actually quite a hard problem to try and
resolve.
We also need to look at the error responses when dealing with
Ajax/JSON. If it is up to the end-developer to implement better Ajax
error handling mechanisms then it should at least be documented well.
To manage notifications about this bug go to:
https://bugs.launchpad.net/phpdevshell/+bug/934297/+subscriptions
References