In my DataTables, I want to avoid repetition and keep the base address in web.config file. Then, I just need to concatenate the variable part. Here's what I've done without success and the message from browser (IE 11):
"DataTables warning: table id=configurationTable - Ajax error..."
Javascript:
$(document).ready(function () {
var url = @Html.Raw(Json.Encode(ConfigurationManager.AppSettings["BaseAddress"])) + "Configuration";
$('#configurationTable').DataTable({
ajax: {
'url': "'" + url + "'", //url is concatenated correctly
'dataSrc': 'value',
},...edited for brevity
Config setting:
<add key="BaseAddress" value="http://myServer:8083/api/"/>
Update: I also have tried this without putting url in quotes. Chrome show a 406 error - Not Acceptable
Update 2: The Web API service I'm calling has OdataControllers and ApiControllers. The prefixes for both are the same, so the OData ones need to be configured first in the WebApiConfig. Plus, no quotes on the url argument.
'url': url,. There is no need to add single quotes.