最近搜索


没有最近搜索

jQuery read content in external html file inside project

已回答


已于 2021年7月22日 发布

 

In my iframe.html, I have "select element" and when it change, it will call my javascript function which read content from external html file, located at assets/template/xxx.html, using command $.get("path_to_file", callback(){}) . 

When I test on my local, the program run properly but when I deploy to server it get error below:

https://521412.apps.zdusercontent.com/521412/assets/templates/xxx.html 403

Please suggest

Thanks

 


1

2

2 条评论

image avatar

Christopher Kennedy

Zendesk Developer Advocacy

Hi Pakpoom,

After the app is uploaded, the asset files are not accessed from the same path within the assets directory as they are when the app runs locally.  To account for this, you can use the assetURL API to get the fully qualified URL that points to the file.

So when using jQuery to retrieve a test.html file that exists in assets/templates​, use the following approach to send the request to the asset's fully qualified URL: 

client.get('assetURL:templates/test\\.html').then(function(asset){
$.get(asset['assetURL:templates/test\\.html'],
//success callback function
);
});

Thanks,

1


 

Hi Christopher,

Your solution is work!! Thank you very. 

0


请先登录再写评论。

找不到所需的内容?

新建帖子