script# - Newbie How do I send Json information using scriptsharp to a web service -


i have modified sample demo try send json object rather string. web site see string of value [object] rather json text. need change.

namespace demoscript { // [imported] // [ignorenamespace] public sealed class person  {     public string firstname;     public string lastname; }  [globalmethods] internal static class hellopage {      static hellopage() {         // add script runs on startup script loaded         // page          element hellobutton = document.getelementbyid("hellobutton");          person p = new person();          hellobutton.addeventlistener("click", delegate(elementevent e) {             inputelement nametextbox = document.getelementbyid("nametextbox").as<inputelement>();              p.firstname = nametextbox.value;             p.lastname = "surname";              xmlhttprequest xhr = new xmlhttprequest(); //          xhr.open(httpverb.get, "/helloservice.ashx?name=" +   nametextbox.value.encodeuricomponent());             xhr.open(httpverb.get, "/helloservice.ashx?name=" + p);              ...         }     } } 

if pass p.fisrtname works expected.

you need json encode object first. in script# native json mapped system.serialization.json, has methods stringify() , parse().

documentation on native json: https://developer.mozilla.org/en/using_native_json.

for support browsers without native json, can include popular script: https://github.com/douglascrockford/json-js.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -