Posting from web role to another web role Windows Azure -


i have 2 web roles in solution, 1 main web app , i'd act api both web app , mobile applications.

they both work independently of each other struggling post data view in web app's role api controller in api's role.

this method in api controller:

public void post([frombody]string value) {     var post = (post)jsonconvert.deserializeobject(value, typeof(post));     addpost(post); } 

and here javascript view trying post from:

<script>     $(function () {         var onpost = function () {             $.post("http://localhost:8081/api/post",                 {                     "value": $('#postform').serialize()                 }             ).success(function () {                 alert("success");             }).fail(function () {                 alert("failure");             });         };     }); </script> 

edit:

i not getting error, nor either of alert functions being called. however, on clicking button fires event, url changes include entries of form has been serialized.

it better make api call server side such mvc controller in web app. can include security key , other things don't want expose others. when make api call directly javascript subdomain or url, creating cross-domain ajax request.

in javascript, make ajax call controller action in web app. web app make call whatever service talking to.

you can test api fiddler post/get/put/delete requests.

if want directly call javascript , host web roles under different subdomains, need make cors request: http://www.html5rocks.com/en/tutorials/cors/. can @ related question: running webapi alongside mvc project in azure


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -