MarsHutPage 1/8Joomla raiseError with AJAX get messageHope that helps....

On Thu, Mar 21, 2013 at 3:21 PM, Evandromar MachadoAnswer byDmitry Rekunon 2013-03-22T01:59:25-04:00That's interesting laoneo. What is the purpose of closing an application?

DmitryAnswer byAllon Moritzon 2013-03-22T05:58:56-04:00It is a gracefull die...Answer byPiotr_czon 2013-03-22T06:12:42-04:00There is/was a Pull request to move JResponseJson to it's own packagewithin the platform, I think it could be quite beneficiary to CMS:https://github.com/joomla/joomla-platform/pull/1596

Do you think we can revive it?Answer byAllon Moritzon 2013-03-22T07:12:46-04:00Before I was using the class from the language package I searched the wholecms up and down to have a library class like this one, but there wasn't oneso I've used the one from the language package. I'm pretty sure this pullrequest would be a huge benefit for the extension developers as the peoplerequest more and more from my extensions not to have page loads but insteadajax calls.Answer byPiotr_czon 2013-03-22T07:35:16-04:00I Agree, there should be a standard and solid foundation for creatingajax/json responses.Let's try to get it merged sake of all developers.

- Do you think this should be part of Framework o CMS?- Do you want to add/ change something in package?

Maybe we should create explicit post like 'feedback for JJsonResponsepackage' to get feedback from others, but IMHO this is ok for generaluse.Answer byAllon Moritzon 2013-03-22T07:54:48-04:00You will have my vote!Answer byMichael Babkeron 2013-03-22T09:15:51-04:00I'd +1 it if we can standardize its use in core. Right now, there's a JSONresponse class in the admin com_finder (used with the indexer) and theinstall app (since that's using AJAX for all requests). So, abstract outthe response class and make it extendable for special use cases, and I thinkwe have a win-win situation.

anAnswer byDavid Hurleyon 2013-03-22T09:21:28-04:00I agree with Michael. If we can standardize an approach and take theprocesses currently in place but abstract them out for use elsewhere thatwould be an ideal situation.

Thanks,David HurleyAnswer byChranecoon 2013-03-22T10:27:42-04:00Hi,

when I created that pull request to the platformhttps://github.com/joomla/joomla-platform/pull/1596it was not accepted and only supported by very few people, but it seemsthat there are more supporters now.So, I could redo the patch for the CMS, if it is accepted this time.

One other thing has to be fixed together with this. I created a post herefor that:https://groups.google.com/forum/#!topic/joomlabugsquad/YhxiAL5iaf8and a tracker issue here:http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEditë¶é²_item_id=29425but it seems that nobody is interested in fixing this.

If it would be fixed, sending Ajax responses could be done in a very cleanand beautiful way with *.json.php controllers and without having to useugly things like $app->close();

RegardsChranecoAnswer byEvandromar Machadoon 2013-03-22T11:34:33-04:00I got so many calls in my ajax component that would be difficult to countthem.MarsHutPage 3/8Joomla raiseError with AJAX get messageI can get answers json perfectly, but if something's wrong as errordatabase for example, the application "dies" and I get the error of noreturn!It would be great to have that back.I believe that by adding that the platform would be very good.Answer byPiotr_czon 2013-03-22T13:31:46-04:00Using JJResponseJson, you'd do:

I'm not sure about JResponseJson use with for this specification:client-side framework might have problems with reading response witherror status codes (400-500). This is doable for MooTools but I knowlittle about jQueryAnswer byAlonzo Turneron 2013-03-22T14:47:51-04:00Perhaps, I misunderstand, but I believed there is already a standard way ofdoing this. When I create an AJAX request, I add the parameter"format=json". Then, the data returned is in JSON format becauseJDocumentJSON already handles all of the MIME type headers and closes theapplication for me. If I encounter an error while retrieving data in themodel, I can pass that error message back to JavaScript by adding the errorinformation to my JSON output.

I would also add an onFailure handler to my AJAX request, just as I have anonSuccess handler. Here is an example:

Additionally, shouldn't much of this get addressed with the RESTFUL WebServices API work that is being done in the platform to respond to datarequests? That whole API project is based around the idea of communicatingwith joomla using JSON. I don't want to get behind any more changes thatonly last for one version. I don't want to see this pull requestimplemented if the Web Services groups is just going to turn around andundo it in 6 months.Answer byEvandromar Machadoon 2013-03-22T15:22:40-04:00Hello, forgive me if I'm doing it wrong!!I managed to capture responses when exceptions occur, could make it workperfectly.Joomla.renderMessages (data.messages) had no effect why?The error messages were instanceof Exception, I changed the code below andMarsHutPage 5/8Joomla raiseError with AJAX get messagenow everything works perfectly, the co code below.Thanks for the help and all.

Web services proof-of-concept codehttps://groups.google.com/group/joomla-dev-cms/browse_frm/thread/986e7a96900e03ce#Answer byJurian Evenon 2013-03-31T03:51:37-04:00FOF already includes JSON, you might want to check it out (of coursethere's more logic in FOF which is needed to accomplish this):https://akeeba.assembla.com/code/fof/git/nodes/master/fof/view/json.php

go to elements folder and get yjsgjson.php , it is custom 50 lines JSONclass from Contsantin,http://www.youjoomla.com/meet-the-team.htmlplease keep the copyrights in tact

now open

elements/yjsgupdate.php

on line 49 you will seerequire('yjsgjson.php');yo will need that in your ajax file

from line 160 - 185 is where the errors are returned and they must be donedifferently for 2.5.x and 3.xin 3.x you must catch (ExceptionTaggedError ResponseJoomla RaiseerrorJson FormatPhp Raiseerror CallsTreating ErrorsRelatedError in Joomla componentJoomla problem at all admin sidebar, after uninstall theme hathor!!!doubt jForm - setFieldAttribute unsetHow to use format=jsonEditing records with id / key negative.MarsHutPage 7/8Joomla raiseError with AJAX get messageGetting a Module AJAX Responsedata format: to json or not to json?Get error from pluginView Onlinehttp://www.marshut.com/kwyx/joomla-raiseerror-with-ajax-get-message.htmlMarsHutPage 8/8