Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi Dmitrig01,
I'm trying to contact you again. Please don't ignore.
As discussed on email, these are simple changes that do not affect the basic structure of the module.
It requires only two changes:
1) Replaced all $_POST for $_REQUEST.
2) Changed the code so that if a callback is set, it will return a json-p.
$callback = $_REQUEST['callback'];
if ($callback) {
header("Content-type: text/javascript");
return $callback ."(". $json .");";
} else {
header("Content-type: application/json");
return $json;
}
Kind regards,
Nick
Comments
Comment #1
ilo CreditAttribution: ilo commentedLets see how this works with #598358: JSON server now allows for JSON/P callback. If you have a patch probably this would go in faster.
Comment #2
ilo CreditAttribution: ilo commentedAndremolnar, any direction on this proposal? can we merge both issues and get this feature working?
Comment #3
yajnin CreditAttribution: yajnin commentedBump.
Comment #4
yajnin CreditAttribution: yajnin commentedJSONP + JSON Server Reference Information
====================================
Please refer to other discussions and JSONP examples:
Updates on this topic
++++++++++++++++
See Issues threads for further discussion regarding inclusion of JSONP in JSON Server
- - > http://drupal.org/node/598358
- - > http://drupal.org/node/624898
+
See tips for getting JSONP working with JSON Server 6.x-2.0-alpha1
- - > http://drupal.org/node/624898#comment-2858192
+
See more discussion from people using it (as well as general JavaScript info, as well as MooTools info)
"JavaScript and Services: JSON Server + JSON + JSONP // + MooTools // Discussions"
- - JSONP info begins about half-way down
- - > http://groups.drupal.org/node/24372
+
See an example of using JSONP (with MooTools) for node.save, node.update
http://drupal.org/node/774116
Comment #5
yajnin CreditAttribution: yajnin commentedNotes for anyone attempting Nick's changes in 6.x-2.0-alpha1
- - I made the prescribed fixes (for example "$_REQUEST")
Everything works fine. Great.
- - Except GZIP
I didn't spend much time on this issue, so your mileage may vary...
It threw an error the first time I tried it with JSONP and in my test dev this functionality is unnecessary.
The GZIP functionality in 6.x-2.0-alpha1 -- I essentially commented most of that method out.
I don't necessarily advise doing this unless you are able to debug. As stated, I didn't spend much time and am not sure of the consequences :)
- - - Philosophically, pertaining to the community's attempts to have official support of JSONP :
I have questions about whether this GZIP functionality should be included in the module. It seems to be placed out of scope. Even though it's a good idea. More in scope, I'd sooner see features like JSONP have official support first.
There's demand. There are test environments. Based on obvious use cases. (That contradict the concerns about security.) And there is a code solution.
JSONP 5+
Comment #6
voxpelli CreditAttribution: voxpelli commentedIsn't this very much a duplicate of #598358: JSON server now allows for JSON/P callback? There are some valid points made in #2 in that issue that still aren't fixed - no need for a new issue to get them fixed?