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.
When creating a JSON data document for a page in Views, the JSONP prefix is not prefixed to the JSON string, nor are the parentheses added. I have not tested all the cases, but I noticed the problem with these values set in the settings form:
View API mode = false (unchecked)
JSON data format = simple
JSONP prefix = someString
Looking at the code, it looks like the file views/theme/views-views-json-style-simple.tpl.php has a bug at line 29. Instead of
if (isset($_GET[$jsonp_prefix]) && $jsonp_prefix) {
$json = $_GET[$jsonp_prefix] . '(' . $json . ')';
}
it probably should just have
if ($jsonp_prefix) $json = "$jsonp_prefix($json)";
which seems to work in the other cases. I made this change in my copy of the code and it works.
Comments
Comment #1
ontoligent CreditAttribution: ontoligent commentedComment #2
ontoligent CreditAttribution: ontoligent commentedAh, I see this has been addressed in another issue. See "JSONP prefix disappears" https://drupal.org/node/2090423
Comment #3
ontoligent CreditAttribution: ontoligent commentedComment #4
yannickooDuplicate of #2090423: JSONP prefix disappears.