asp.net mvc - Uncaught SyntaxError: missing ) after argument list despite no missing ')' in javascript -


why receiving error when button click calls function?

function showfaultmessage(message) {      $.ajax({         url: '/home/message/',         data: json.stringify(message),         type: 'post',         contenttype: 'application/json; charset=utf-8',         success: function(result) {             var w = window.open("/home/message", "fault message", "width=400, height=400");             $(w.document.body).html(result.responsetext);         }     }); }; 

i've looked @ other questions error, none seem apply here. appear have brackets , parenthesis present.

this button calls function. appears ok well:

 return new htmlstring(string.format("<input type='submit' id='btnshowfault' onclick='showfaultmessage({0})' value='fault' />", item.fault.message)); 

i needed put double quotes when building htmlstring button in parameter function call so:

return new htmlstring(string.format("<input type='submit' id='btnshowfault' onclick='showfaultmessage(\"{0}\")' value='fault' />", item.fault.message)); 

Comments