I am developing a MVC application with Remote validations. I am getting a No element found error in the browser console. I was getting so many Jquery not found errors that I could manage to remove by rendering the required Scripts. Now I have only one error in the browser console.
My View Script : Placed in the footer
@section Scripts {
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/scripts/jquery-1.10.2.js")
@Scripts.Render("~/Scripts/jquery.validate.min.js")
@Scripts.Render("~/Scripts/jquery.validate.js")
@Scripts.Render("~/Scripts/jquery.validate.unobtrusive.js")
@Scripts.Render("~/Scripts/jquery.validate.unobtrusive.min.js")
@Scripts.Render("~/Scripts/jquery-1.10.2.min.js")
@Scripts.Render("~/Scripts/jquery-ui-1.11.4.min.js")
@Scripts.Render("~/~/Scripts/jquery.unobtrusive-ajax.js")
}
In layout : Before the body (based on a suggestion I read)
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
<script src="@Url.Content("~/Scripts/jquery-ui-1.11.4.min.js")"></script>
How can I get this working? I have used remote validation and I suppose the Jquery used for the validation is missing in my code. But I have added all the Script files that was mentioned in the Remote validation tutorial I followed (I have added more though).
Remote Validation
[HttpPost]
public JsonResult DuplicateFamilyName(string FamilyName, int FamilyID)
{
//bool idExists = db.LsystemFamily.Any(id=>id.LsystemFamilyID.Equals(FamilyID));
if (FamilyID == 0)
{
bool exists = db.LsystemFamily.Any(x => x.FamilyName == FamilyName);
//var name = db.LsystemFamily.Where(x => x.FamilyName.Equals(FamilyName, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
return Json(!exists, JsonRequestBehavior.AllowGet);
}
else
{
bool exists = db.LsystemFamily.Where(x => x.LsystemFamilyID != FamilyID).Any(x => x.FamilyName == FamilyName);
//var name = db.LsystemFamily.Where(x => x.FamilyName.Equals(FamilyName, StringComparison.CurrentCultureIgnoreCase) && x.LsystemFamilyID != FamilyID).FirstOrDefault();
return Json(!exists, JsonRequestBehavior.AllowGet);
}
}
EDIT
getPreventDefault() sollte nicht mehr verwendet werden. Verwenden Sie stattdessen defaultPrevented. jquery-1.10.2.js:5389:0
Kein Element gefunden send:1:1
Kein Element gefunden send:1:1
Kein Element gefunden send:1:1
Kein Element gefunden
Edit:
I have removed the Json validation from my program. Still it doesn't resolve the issue. Based on Torm's comments, i have done the http traffic analysis and have found there are no missing or broken requests and responses. Still I have the create button not working. Not posting any values.