weixin_33734785 2017-08-31 11:34 采纳率: 0%
浏览 121

本地JSON文件上的getJSON

So I have a JSON file which contains some data, I've been trying to send a request from a JavaScript file using $.getJSON to retrieve that file but I'm unsure how to do so, is it possible to send a request directly to that file without having to setup request-map or view-map? If so where would store the file to make it publicly available.

I've tried using <@ofbisContentUrl> as it is stored in /images/[...]:

$.getJSON(
    '<@ofbizContentUrl>/images/[...]</@ofbizContentUrl>',
    function (data, text_status, jqXHR) {
        map.load_layer_data(data, [layer_file, layer_type]);
    }
).error(function (jqXHR, text_status, error_thrown) {
    busy.unset();

    /** Error reporting later... **/
    BootstrapDialog.show({
        type: BootstrapDialog.TYPE_DANGER,
        message: 'Failed to data for layer data.'
    });
});

This failed, so I then tried to setup a request-map/view-map but the again had no success,

<request-map uri="frs_get_mapping_points">
    <security https="false" auth="false"/>
    <response name="success" type="request" value="frs_json"></response>
</request-map>    

The documentation lacks any suitable information in regards to making a simple AJAX request to a local file hence I'm completely stuck. Any ideas how this can be achieved?

  • 写回答

1条回答 默认 最新

  • weixin_33735676 2017-08-31 12:56
    关注

    My JavaScript request was not parsing the Freemarker expression <@ofbisContentUrl> as a result it was not finding the file. What I had to do was in my .ftl file create a dummy variable with the location stores using <@ofbisContentUrl> and manipulate the string using .replace() to point it to the correct location.

    评论

报告相同问题?

悬赏问题

  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 Arcgis相交分析无法绘制一个或多个图形