Using ajax to call a rest api

Hi,

I have a test api written in Visual studio which is running on localhost.

I am trying to call one of the end point actions using ajax (new to ajax) and can not seem to get a call to success or even fail. i can run the rest service in a browser (http://localhost:51099/api/values) and it runs fine and returns the following

[{"id":1000,"connote":"Connote 1000"},{"id":1001,"connote":"Connote 1001"}]

in a js file i have the following method

function ajaxTest(){ $.ajax({ type: "GET", dataType: "json", async: true, url: "http://localhost:51099/api/values", error: function(request, status, error) { alert(request.responseText) }, success: function(data) { alert('success'); }<br /> } }); } I have my bootstrap studio project previewing on http://127.0.0.1:8000

I have tested to ensure the function is actually being called on the button click and it works, just the ajax call is not firing.

Any assistance will be greatly appreciated. Cheers.

Ok,

I managed to get this working, my issue was CORS, i disabled this in chrome using the below command by entering this into the windows run box chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security

working sample of my ajax call is as follows.

function ajaxTest(){ $.ajax({ crossdomain:true, type:"GET",<br /> url: "http://localhost:51099/api/values/",<br /> success: function(r){ alert(r[0].connote);<br /> } }); }