Since the ServiceFramework.js as it seems needs to be in a $(document).ready to work, is there a better way than the sample below to handle it? I'm not really a JavaScript/jQuery expert. What would be the best way to use it in an AngularJS application?
<asp:Button ID="btnHelloWorld" runat="server" Text="Get Hello World" OnClientClick="getHelloWorld(); return false;" />
<script type="text/javascript">
var getHelloWorld;
$(document).ready(function() {
var sf = $.ServicesFramework(<%= ModuleId%>);
var exampleControllerPath = sf.getServiceRoot('DataExchange') + 'Example/';
getHelloWorld = function () {
try {
$.ajax({
type: "GET",
contentType: "application/json;charset=utf-8",
url: exampleControllerPath + 'HelloWorld',
beforeSend: sf.setModuleHeaders,
data: [],
success: function(result) {
result);
},
error: function(xhr, status, error) {
xhr.responseText);
}
});
} catch (e) {
//Shouldn't do this but it's just for testing
e.stack);
}
};
});
</script>