c# - How to make a search in AJAX? -


i want make research in ajax it's not working, don't know i'm doing wrong.

code in view dom load :

$(function () {         jquery(document).ready(function ($) {             var options = { $autoplay: true };             var jssor_slider1 = new $jssorslider$('slider1_container', options);         });         templatecategories = handlebars.compile($('#categoriestemplate').html());         templateanimes = handlebars.compile($('#animestemplate').html());         templateperso = handlebars.compile($('#persotemplate').html());          $.getjson("animes/getcategories", null, function (data) {             var result = templatecategories(data);              $('#categoriesoutput').html(result);              //fonctionne pas ça chie ma vie :(             $("#btn_rech").on("click", function () {                 $.getjson("animes/getanimesordered", { search: $("#rech").val() }, function (data) {                     var output = "";                     (var = 0; < data.d; i++) {                         output += "<div id='animesoutput' onclick='getpersonnages(\"" + data.d[i] + "\")'>" + data.d[i] + "</div>";                     }                     $("#animesoutput").html(output);                     console.log($("#rech").val());                 });             });         });     }); 

maybe can if add code :

<div id="rech">     rechercher un anime en particulier? : <input type="text" id="rech" placeholder="anime" />     <input type="button" id="btn_rech" value="rechercher" /> </div>  <div>     <h3>catégories</h3>      <div id="categoriesoutput">      </div>      <h3>animes</h3>      <div id="animesoutput">      </div>      <h3>personnages</h3>      <div id="persooutput">      </div> </div> <script id="categoriestemplate" type="text/x-handlebars-template">     {{#each}}     <h3 class="categories" onclick="getanimes({{categoryid}})">{{categorynom}}</h3>     {{/each}} </script>  <script id="animestemplate" type="text/x-handlebars-template">     {{#each}}     <h3 class="animes" onclick="getpersonnages({{animeid}})">{{animenom}}</h3>     {{/each}} </script>  <script id="persotemplate" type="text/x-handlebars-template">     {{#each}}     <h3 class="perso">{{personnagenom}}</h3>     {{/each}} </script> 

method in controller :

public jsonresult getanimesordered(string search)     {         var animetriees = db.animes.where(s => s.animenom.tolower().contains(search)).tolist();          return json(animetriees, jsonrequestbehavior.allowget);     } 

i got error : http://localhost:10760/animes/getanimesordered?search=dragon 500 (internal server error)

here's printscreen :

enter image description here

do have proper annotation set on action?

i guess should this

[httpget] public jsonresult getanimesordered(string search) {     var animetriees = db.animes.where(s => s.animenom.tolower().contains(search)).tolist();      return json(animetriees, jsonrequestbehavior.allowget); } 

(this meant comment more answer, i'm low on rep)


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -