javascript - How to pass a variable in ajax append function (into html element with razor)? -


i need pass id of object html element (razor part), doesn't recognize it. id not in scope, or something. there way pass value razor part of html element in append function?

$.ajax({         data: data,         url: url + "?searchterm=" + data      }).success(function (response) {          console.log(response);         var table = $('#companytable');         var tbody = table.children('tbody');         tbody.html("");         var textbox = document.getelementbyid("searchbar");         textbox.value = "";          tbody.append(             "<tr><td>" +response.companyname + " </td><td>" +                        response.companyidnumber + "</td><td>" +                        response.companytaxnumber + "</td><td>" +            "<p><button onclick=\"location.href='@url.action("edit", "company", new { @id = response.companyid  })'\"> edit</button></p>" +                            "</td></tr>"                 );             table.removeclass("hidden");             var originaltable = $('#originaltable');             originaltable.remove();          }).error(function (response) {             console.log(response);         });     } 

thank you.

i things way:

+ "<p><button onclick=\"location.href='@(url.action("edit", "company"))?id=" + response.companyid + "'\">edit</button>" 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -