简体   繁体   English

Javascript 返回 System.InvalidOperationException: Unexpected new line Error

[英]Javascript returns System.InvalidOperationException: Unexpected new line Error

I'm currently trying to write a mailto form which has the body already created.我目前正在尝试编写一个已经创建正文的 mailto 表单。 For the moment I'm keeping it simple and trying to just put an email, address and name into the body of the email to be sent.目前,我保持简单,并尝试将电子邮件、地址和姓名放入要发送的电子邮件正文中。 When I do this it returns the error当我这样做时,它会返回错误

System.InvalidOperationException: Unexpected new line System.InvalidOperationException:意外的新行

Here's the HTML:这是 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>

And here's the relevant JavaScript:这是相关的 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);
    });
}

};

I noticed that the error always returns the value for name.我注意到错误总是返回 name 的值。

Here's the full error code:这是完整的错误代码:

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)

So, I managed to fix the issue.所以,我设法解决了这个问题。 I realized I had made the issue too complicated and fixed it using some simple code from Aitor in this Anwser .我意识到我把问题弄得太复杂了,并在这个Anwser 中使用 Aitor 的一些简单代码修复了它。 I basically just rewrote it to fit the way Aitor had his laid out.我基本上只是重写它以适应 Aitor 的布局方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 代码抛出System.InvalidOperationException - Code throws System.InvalidOperationException Blazor 服务器端应用程序在重新加载期间抛出“System.InvalidOperationException:此时无法发出 JavaScript 互操作调用。...” - Blazor server side application throwing "System.InvalidOperationException: JavaScript interop calls cannot be issued at this time. ..." during reload Javascript Promise返回意外的令牌错误 - Javascript promise returns unexpected token error HttpContext.Request.Form 引发了“System.InvalidOperationException”类型的异常 - 为什么? - HttpContext.Request.Form threw an exception of type 'System.InvalidOperationException' - why? Javascript错误对象数组新增了意外令牌 - Javascript error Unexpected token new for an object array Javascript str.search(“?”)返回Unexpected Quantifier错误 - Javascript str.search(“?”) returns Unexpected Quantifier error 语法错误:意外标识符 - 高阶 Function 返回 JavaScript 中的 Function - Syntax Error: Unexpected Identifier - Higher Order Function that Returns a Function in JavaScript JavaScript错误:意外的匿名System.register调用 - JavaScript error: Unexpected anonymous System.register call AsyncStorage 返回意外错误 - AsyncStorage returns unexpected error JavaScript .js文件的第1行中输入错误的意外结束 - Unexpected end of input error in line 1 of JavaScript .js file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM