I have a jquery request send at the page load time to which I am getting an error in the console log that says: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
Here is my ajax request:
$(document).ready(function() {
(function(){
console.log("ran");
$.ajax({
type: "GET",
url: "https://clas-test4.uconn.edu/Employees/Edit/22",
dataType: "json",
success: function (data) {
console.log("Success: " + data);
empData = data;
}
});
})();
});
I am using /22 for the id just for testing purposes. Here is my controller which receives this GET request:
public ActionResult Edit(int? id)
{
if (id == null)
{
return Json("Error: Id does not exist", JsonRequestBehavior.AllowGet);
}
employee employee = db.employees.Find(id);
if (employee == null)
{
return Json("Error: employee does not exist", JsonRequestBehavior.AllowGet);
}
return Json(employee, JsonRequestBehavior.AllowGet);
}
Try changing the URL in your get request from:
to something like this:
I'm not sure exactly what conditions you are testing your code, but I suspect you are attempting to debug locally, in which case your server may not have that URL configured yet.
EDIT:
Also, depending on how your route configuration is set up, you may need the URL query string defined explicitly, such as: