Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by JBoy · Sep 28, 2013 at 06:20 AM · wwwjsonhtml

Upload/store string to html/json script??

The html code below : Website.

 <html>
 <body>

 <p>
 String Value: <span id="val"></span>  
  
 </p>  

 <script>
 var JSONObject = { "stringVal":"This is a string" };

 document.getElementById("val").innerHTML=JSONObject.stringVal 
 </script>

 </body>
 </html>

And the unity JavaScript code:

 var siteURL = "http://zinfection.x10host.com/index.htm";

 function Start (){
     var form = new WWWForm();
     form.AddField("stringVal", "This string has been changed");

     var request = new WWW(siteURL, form);

     yield request;

     if(request.error){
         Debug.Log("Request error: " + request.error);
     }else{
         Debug.Log("Returned text" + request.text);
         Debug.Log("Returned data" + request.data);
     }
 }

I know this isn't setup correctly, but its the best I could do with the knowledge I have. What i'm trying to do is modify the JSONObject stringVal in the html via unity, and it change on the site. I'm planning to have a player leaderboard or save player info on this site, but i need to get this working right first. If anyone knows how to help/what im doing wrong please let me know, its very greatly appreciated! :)

What I need to do is be able to save to the server and access the string variable in unity. I don't know if i've explained very well.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sacredgeometry · Sep 28, 2013 at 11:27 AM 0
Share

I see you have asked a few more questions since I answered your post.

I will try to explain a few things.

Websites are locally cached/ run on a client ... in most cases your browser... i.e. chrome/ firefox etc

To get updated information they require sending requests to the server which then posts the information back in what is called a postback. This normally requires a refresh of the page but you can do what is called a partial postback that gets around this. The question really is what is it that you are trying to achieve here?

Do you need to display information in realtime on the screen without a postback? Because personally I am not sure why you wouldnt try to build that into your game UI as it will probably be a lot easier to manage.

If you just want a way to store players scores in a league table then you have a lot more options and there are much nicer ways to do it ... for example you could use entity framework to store them in a SQL database or use a C$$anonymous$$S like umbraco where you could actually store them as document types inside the cms... which would be easier for a human to manage or for you to use on your website.

You could still do what I originally said and store it in xml or JSON and then pull that into the page using xslt or a user control.

I think learning some basic asp.net might benefit you if you are trying to do these things.

If anyone sees any faults in my advice please dont hesitate to correct me.

avatar image JBoy · Sep 28, 2013 at 11:37 AM 0
Share

Ok thank you, looks like i'll need to do some researching

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

POST using WWW isn't working 0 Answers

Retreive Jsonfile and Read It 0 Answers

Using html JSON script to store varibles 1 Answer

Run website's scripts. 0 Answers

Edior sends a bad www request while webplayer does not 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges