Skip to content

Commit

Permalink
Merge pull request #1 from SBPrakash/SLING-9981-remove-jquery-dependency
Browse files Browse the repository at this point in the history


added javascript to make ajax call instead of jquery ajax as this req…
  • Loading branch information
Prakash SB committed Dec 10, 2020
2 parents 33338b5 + 3f403c4 commit 013365d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
@Component
public class JsiGenerator implements IncludeGenerator {
private static final String TEMPLATE_FILENAME = "generators/jquery.html";
private static final String TEMPLATE_FILENAME = "generators/javascript.html";

private static final String UUID_FIELD = "${uniqueId}";

Expand Down
35 changes: 35 additions & 0 deletions src/main/resources/generators/javascript.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<div id="${uniqueId}"></div>
<script type="text/javascript">
if (window.XMLHttpRequest) {
var xhr = new XMLHttpRequest();
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.timeout = 10000;
xhr.onload = function () {
if (xhr.status >= 200 && xhr.status < 300) {
document.getElementById('${uniqueId}').innerHTML = xhr.responseText;
}
};
xhr.open('GET', encodeURI("${url}"));
xhr.send();
}

</script>
<noscript>Your browser does not support JavaScript. Some components may not be visible.</noscript>

0 comments on commit 013365d

Please sign in to comment.