Skip to main content
1-Visitor
February 20, 2025
Question

VuforiaStudio请求服务器数据

  • February 20, 2025
  • 2 replies
  • 933 views

提供一段js代码,满足以下条件:1、请求服务器数据 2、在vuforia studio的Home.js里面使用3.请求的数据如何解析后绑定不同的文本显示在2D  UI上

2 replies

Community Manager
February 20, 2025

Hi @FY_10283333,

 

Thank you for your question regarding the JavaScript code for Vuforia Studio. To better assist you, please add more context to your topic.
Possibly on the below points?
 

  1. Could you specify the type of data you are requesting from the server and the API endpoint you are using?
  2. Are there any specific requirements or constraints for using the code within the Home.js file in Vuforia Studio?

This information will help the community members understand your requirements more clearly and provide a more accurate and helpful response. 

 

Regards,

Vivek N
Community Moderation Team.

1-Visitor
February 20, 2025

你好

    1.请求到的数据类型是Json字符串

    2.特定要求没有,就是注意一下请求的链接错误,超时等给出提示即可

Best Regards!

21-Topaz I
February 20, 2025

Hi @FY_10283333 ,

To your points:
Provide a piece of js code that meets the following conditions: 
Your Question 1. request server data - what kind of server /Thingworx server . And what kind of data ? 
Answer: Currently because there is CORS resticion you could contact only as server located on the same domain The code will differs depending on that , what kind of server object you need to access . PTC supports only server request where data is requested but access depend on that what is the server database /Things and properties what need to be requested and if there are specific requirements.
 
2. use inside Home.js in vuforia studio -
Answer any JS code could be used there so far It is supported on the mobile platforms  
3. how the requested data is parsed and then bound to different text to be displayed on the 2D UI
- you do not need to parse /that what  in terms of Javascript/  but to convert it  to string (JSON.stringify() when it is a json object) or .toString() methoded if you have an object which supports that method and then you could display it on widget wich support the text property 
example:
$scope.myText="any text there";
$scope.setWidgetProp("myLabel-1","text",$scope.myText);
Community Manager
February 27, 2025

Hello @FY_10283333,

 

It looks like you have some responses from some community members. If any of these replies helped you solve your question please mark the appropriate reply as the Accepted Solution. 
Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.

Thanks,
Vivek N.
Community Moderation Team.