I need help with an ASP.NET MVC web page that requires user input to create an XML file using a javascript function. After the user enters information and clicks a button, how can I display the XML created by the javascript method?
In the .cshtml file: For example, let's consider a text box.
<div class="col-md-8">
<input id="NameTextBox" name="Name" type="text" placeholder="Enter a name ..." class="form-control" required="required" autofocus="autofocus" />
</div>
<input id="CreateXml" type="submit" class="btn" value="Create XML" onclick="javascript:createXml()" />
In the .js file:
function createXml() {
var returnXml = "<Hello>" + "\n";
var name = $('#NameTextBox').text();
returnXml = returnXml + name + "\n" + </Hello>;
}
How can I display the 'returnXml' string in a file on the client side? Is it possible to achieve this without posting to an Action (possibly by using ajax)? Any suggestions are appreciated.