User tests: Successful: Unsuccessful:
Internet Explorer older than 10 does not accept
Content-Type: application/json
and would start to download it.
But this one would work for older IE and all new browsers
Content-Type: text/plain
When you send ajax request by jQuery just set header:
$.ajax({
url: ...,
dataType: 'json',
headers: {
Accept: 'application/json'
},
accept: 'application/json'
}).done(function(data, textStatus, jqXHR) {
...
});
and then server would respond with:
Content-Type: application/json
Also we should use
JResponse::toString();
because in ajax method on server side there might be set some other headers by
JResponse::setHeader(...);
And one last thing to discuss is if we should allow to load module language file, because you might want to respond with some message or we leave this to decide by developer in his method
$lang = JFactory::getLanguage();
$lang->load('mod_' . $module);
Next thing to discuss is if we should load module parameters like in:
libraries/joomla/document/html/renderer/module.php
and this give next question if we should pass module ID to ajax call.
All of this can be done by developer if he need this, but in most cases ajax call would be related to one module instance with parameters.
Thanks for your contribution - At this time we are only using github as the place to submit code fixes, the actual reporting of issues and testing fixes is still taking place on Joomlacode.
Please can you:
1) Open an item on the Joomlacode tracker in the appropriate area.
CMS Bug Reports: http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemBrowse&tracker_id=8103
CMS Feature Requests: http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemBrowse&tracker_id=8549
2) After submitting the item to the Joomlacode tracker, add a link to the Joomlacode tracker item here and make sure that you add a link to this GitHub issue or pull request on the joomlacode tracker item.
In this thread actual is
Thanks. Please corret me if I'm wrong, but in your commit piotrmocko@8f4da44, I only see code related to
response Content-Type: text/plain for IE < 10
which I think is superseded by the use of JResponseJson
, please see https://github.com/joomla/joomla-cms/blob/master/components/com_ajax/ajax.php#L146.
I'd suggest creating separate PRs for the other two items, as they are also very good ideas.
I will put later those things as separated PR.
JResponseJson does not change Content-type of response. It only generates encoded output. Content-type is being set by JDocument and if you put in URL format=json then response will have Content-type: application/json, but it would not work in IE < 10 without latest updates.
JRepsonse is now deprecated in favour of the new JApplication classes that came in 3.2 so can we use them please in the PR?
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-05-27 08:02:51 |
I am also wondering what to do with system messages if any was set due to an error or warning.
I am using something like this in my extensions, but I am not sure if it is a good idea. If whole Joomla CMS libraries do not set any message then it would be not necessary.
For example when sending emails is disabled in global configuration you will get
Here is my code if needed