Javascript返回System.InvalidOperationException:意外的新行错误

时间:2018-05-31 11:14:07

标签: javascript jquery html

我正在尝试编写一个已创建正文的mailto表单。目前我保持简单,并试图将电子邮件,地址和姓名放入要发送的电子邮件正文中。当我这样做时,它返回上述错误。这是代码。 HTML:

<form method='post'  enctype="text/plain">
<b>Name:</b><br>
<input type="text" name="personsName" id="personsName"><br>
<b>E-mail:</b><br>
<input type="text" name="mail" id ="mail"><br>
<b>Address:</b><br>
<input type="text" name="address" id ="address"><br>
<input type="submit" value="Send" id="send">
</form>

这是相关的JavaScript:

$(function(){ EGf20a6658.Init(); });

var EGf20a6658 = {

Init: function() {
    if (typeof(OEConfEGf20a6658) === undefined) return;
    var allElements = OEConfEGf20a6658;

    for(var ID in allElements) {
        var $el = $('#'+ID); // The element's main <div> tag
        var properties = allElements[ID]; // element's available properties for JS
        this.InitElement(ID, $el, properties);
    }
},

InitElement: function(ID, $el, properties) {

    var name = $('#personsName').val();
    var mail = $('#mail').val();
    var address = $('#address').val();

    var message = "Hey " + " How are you? You still at "  + " with the email "  + "?";

    var mailtolink = 'mailto:me@domain.com?subject=Regret Permission Form&body=' + encodeURIComponent(message);

    $( '#send' ).on( 'click', function(event) {
    $(this).attr('href', mailtolink);
    });
}

};

正如你所看到的那样,它很简单,但我无法弄明白。但我知道错误总是返回name的值。任何建议或帮助都会很棒。谢谢你提前。

编辑:这是完整的错误代码:

500 - Unexpected new line: k [CRLF].

System.InvalidOperationException: Unexpected new line: k
[CRLF].
   at HttpServer.Tools.StringReader.ReadToEnd(String delimiters)
   at HttpServer.Tools.UrlParser.Parse2(ITextReader reader, Boolean urlDecode)
   at HttpServer.Tools.UrlParser.Parse2(String queryString, Boolean urlDecode)
   at HttpServer.RequestEventArgs.FixPostData(IRequest request)
   at HttpServer.RequestEventArgs..ctor(IHttpContext context, IRequest request, IResponse response)
   at HttpServer.HttpContext.OnRequest(Object sender, FactoryRequestEventArgs e)
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at HttpServer.Messages.MessageFactoryContext.OnMessageComplete(Object sender, EventArgs e)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at HttpServer.Messages.Parser.HttpParser.OnComplete()
   at HttpServer.Messages.Parser.HttpParser.GetBody()
   at HttpServer.Messages.Parser.HttpParser.Parse(Byte[] buffer, Int32 offset, Int32 count)
   at HttpServer.HttpContext.ParseBuffer(Int32 bytesLeft)
   at HttpServer.HttpContext.OnReceive(IAsyncResult ar)

1 个答案:

答案 0 :(得分:0)

所以,我设法解决了这个问题。我意识到我使问题过于复杂并使用Aitor中的一些简单代码修复了这个问题Anwser。我基本上只是改写它以适应Aitor布置的方式。