Ok so this is making me and my collegues scratching our heads.
We have developed our own internal web services api to contact our databases, and thought it would be straightforward to use it with razor, and combine it with knockout js. Well, after a ton of trail and error, it still doesnt work, and we have somehow nailed it down to umbraco blocking the web service.
I have searched around and either solutions we found doesnt work, or the information is inconsistent.
var ViewModel = function() { //Make the self as 'this' reference var self = this; //Declare observable which will be bind with UI self.name = ko.observable("enter name"); self.email = ko.observable("enter email");
getMPerson();
function getMPerson() {
$.ajax({ // the url to the service url: "http://webapi.OURSITE.dk/api/MPersons/123456", // the format that the data should be in when // it is returned contentType: "json; charset=utf-8", // the function that executes when the server // responds to this ajax request successfully success: function (data) { // Update view model properties self.name(data.Name); self.email(data.Email); }, error: function (error) { alert("ERROR STATUS: " + error.status + " STATUS TEXT: " + error.statusText); } }); }
}; // end viewmodel definition ko.applyBindings(new ViewModel()); </script>
What kind of service have you created? .asmx? svc? /base? Also, if you hit F12 in Google Chrome and go to the network tab, do you get any response when invoking your ajax call?
Contacting web services API from a razor script
Ok so this is making me and my collegues scratching our heads.
We have developed our own internal web services api to contact our databases, and thought it would be straightforward to use it with razor, and combine it with knockout js. Well, after a ton of trail and error, it still doesnt work, and we have somehow nailed it down to umbraco blocking the web service.
I have searched around and either solutions we found doesnt work, or the information is inconsistent.
This is our razor script:
Any suggestions? Some oversights or anything?
Hi Frederik,
What kind of service have you created? .asmx? svc? /base? Also, if you hit F12 in Google Chrome and go to the network tab, do you get any response when invoking your ajax call?
All the best,
Bo
is working on a reply...