How To To Use Struts 2 Tags In Jquery As String July 31, 2024 Post a Comment Not able to use Struts2 tags in jQuery as String. This is my div: Solution 1: Since you are using javascript only to append HTML (and not to manipulate it nor the DOM), consider returning a JSP snippet instead.You can find the the complete example here.Also remember to map keypress too, or users using keyboard won't fire the event. It would be something like:<scripttype="text/javascript"> $(document).ready(function() { $("#add").on('keypress click', function(event) { $.ajax({ url: "<s:url action='loadNewRowTemplateWithAjaxAction'/>", }).done(function(result) { $(".row").append(result); }); }); }); </script>CopyThis let you keep a clean JSP and perform operations server-side, like checking if it's possible to add a new row, or updating a row counter in session, and so on...Solution 2: You can't use Struts tags that generate HTML in the javascript variable as string, because the generated code should escape quotes.Baca JugaJquery Load Function Not Referring Master Page Script FilesUsing Google Channel Api On The Client Side By Embedding Javascript In Java Using Rhino Or Standard Inbuilt Javascript Support?How Can I Validate A Url In Javascript Using Regular Expressionjavascript string requires quotes around the content and every quote inside the content should be escaped, so it doesn't end a string content.You can also try with single or double quotes to delimit a string value, but without properly escaping it will fail before it's rendered. Instead of generating HTML from the Struts tags in javascript variable use Ajax to load HTML returned as Ajax response. Share You may like these postsExecute A Function After Changing Location.hrefHow To Put Loading Message In Iframe Before Page Was LoadedSetstyleclass Method Is Overriding The Already Defined StyleclassMenu Mouseenter Mouseleave Click Post a Comment for "How To To Use Struts 2 Tags In Jquery As String"
Post a Comment for "How To To Use Struts 2 Tags In Jquery As String"