Asp.net 基于vb.net的ajaxpost

Asp.net 基于vb.net的ajaxpost,asp.net,ajax,vb.net,Asp.net,Ajax,Vb.net,我需要通过我的vb.net页面发布一篇AJAX文章。这篇文章还附加了验证文章所需的xml文件,然后将其提交到链接。我没有得到任何错误,当我做后,但该文件没有得到提交也。我会将我的代码添加到这个问题中,提前谢谢 Public Shared XMLString As String Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Di

我需要通过我的vb.net页面发布一篇AJAX文章。这篇文章还附加了验证文章所需的xml文件,然后将其提交到链接。我没有得到任何错误,当我做后,但该文件没有得到提交也。我会将我的代码添加到这个问题中,提前谢谢

Public Shared XMLString As String

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim xmldoc As New System.Xml.XmlDocument
    xmldoc.Load("d:/jobfeed.xml")
    XMLString = xmldoc.OuterXml
    ClientScript.RegisterStartupScript(Me.GetType(), "script", POSTtoEP)


End Sub



Public Shared Function POSTtoEP() As [String]
    Dim strurl As String = "https://www.executiveplacements.com/Job_Post_Xml.asp"
    Dim strType As String = "POST"
    Dim sb As New StringBuilder()
    sb.Append("<script type = 'text/javascript'>")
    sb.Append("function POSTtoEP () {")
    sb.Append("$.ajax({")
    sb.Append("type:" & strType & ",")
    sb.Append("url:" & strurl & ",")
    sb.Append("data: { XmlPacket:" & XMLString & ",")
    sb.Append("contentType: application/x-www-form-urlencoded")
    sb.Append("dataType: xml,")
    sb.Append("success: function(data){,")
    sb.Append("},")
    sb.Append("error:function(){")
    sb.Append("alert('Error processing data. Please try again.);")
    sb.Append("}")
    sb.Append("}")
    sb.Append("}")
    sb.Append("});")
    sb.Append("</script>")
    Return sb.ToString()
End Function
公共共享XMLString作为字符串
受保护的子按钮1\u单击(ByVal sender作为对象,ByVal e作为System.EventArgs)处理按钮1。单击
Dim xmldoc作为新的System.Xml.XmlDocument
Load(“d:/jobfeed.xml”)
XMLString=xmldoc.OuterXml
ClientScript.RegisterStartupScript(Me.GetType(),“脚本”,POSTtoEP)
端接头
公共共享函数POSTtoEP()为[String]
Dim strurl作为字符串=”https://www.executiveplacements.com/Job_Post_Xml.asp"
Dim strType As String=“POST”
使某人成为新的架线工
某人加上(“”)
sb.Append(“函数POSTtoEP(){”)
sb.Append(“$.ajax({”)
sb.追加(“类型:“&strType&”,”)
sb.追加(“url:&strurl&“,”)
sb.Append(“数据:{XmlPacket:&XMLString&>,”)
sb.追加(“contentType:application/x-www-form-urlencoded”)
sb.Append(“数据类型:xml,”)
sb.Append(“成功:函数(数据){,”)
某人附加(“},”)
sb.Append(“错误:函数(){”)
sb.Append(“警报('处理数据时出错。请重试。);”)
某人附加(“}”)
某人附加(“}”)
某人附加(“}”)
(某人加上(“}”);)
某人加上(“”)
把某人送回原处
端函数
末级


该代码中缺少引号和大括号。脚本还声明了一个从未调用过的函数

Public Shared Function POSTtoEP() As [String]
    Dim strurl As String = "https://www.executiveplacements.com/Job_Post_Xml.asp"
    Dim strType As String = "POST"
    Dim sb As New StringBuilder()
    sb.AppendLine("<script type = 'text/javascript'>")
    sb.AppendLine("function POSTtoEP () {")
    sb.AppendLine("$.ajax({")
    sb.AppendLine("type:""" & strType & """,")
    sb.AppendLine("url:""" & strurl & """,")
    sb.AppendLine("data: { XmlPacket:""" & XMLString & """},")
    sb.AppendLine("contentType:""application/x-www-form-urlencoded"",")
    sb.AppendLine("dataType: ""xml"",")
    sb.AppendLine("success: function(data){ ")
    sb.AppendLine("alert(data);")
    sb.AppendLine("},")
    sb.AppendLine("error: function(error, message){")
    sb.AppendLine("alert('Error processing data. Please try again.');")
    sb.AppendLine("}")
    sb.AppendLine("});")
    sb.AppendLine("};")
    sb.AppendLine("POSTtoEP();")
    sb.AppendLine("</script>")
    Return sb.ToString()
End Function
公共共享函数POSTtoEP()为[String]
Dim strurl作为字符串=”https://www.executiveplacements.com/Job_Post_Xml.asp"
Dim strType As String=“POST”
使某人成为新的架线工
某人加上一行(“”)
sb.AppendLine(“函数POSTtoEP(){”)
sb.AppendLine($.ajax({”)
sb.AppendLine(“类型:”&strType&“,”)
sb.AppendLine(“url:”&strurl&“,”)
sb.AppendLine(“数据:{XmlPacket:”&XMLString&“}”)
sb.AppendLine(“contentType:”application/x-www-form-urlencoded“”)
sb.AppendLine(“数据类型:“xml”)
sb.AppendLine(“成功:函数(数据){”)
某人加上一行(“警报(数据);”)
某人附言(“},”)
sb.AppendLine(“错误:函数(错误,消息){”)
sb.AppendLine(“警报('处理数据时出错。请重试');”)
某人加上一行(“}”)
sb.附录(“};”)
某人追加(“};”)
某人附言(“POSTtoEP();”)
某人加上一行(“”)
把某人送回原处
端函数

此代码呈现正确的javascript。但是,如果Job_Post_Xml.asp未返回“application/x-www-form-urlencoded”,则需要修改ContentType。否则将产生解析错误。我相信Job_Post_Xml.asp有gzip编码,但无法在这里测试它,因为它是一个跨域请求。

该代码中缺少引号和大括号。脚本还声明了一个从未调用过的函数

Public Shared Function POSTtoEP() As [String]
    Dim strurl As String = "https://www.executiveplacements.com/Job_Post_Xml.asp"
    Dim strType As String = "POST"
    Dim sb As New StringBuilder()
    sb.AppendLine("<script type = 'text/javascript'>")
    sb.AppendLine("function POSTtoEP () {")
    sb.AppendLine("$.ajax({")
    sb.AppendLine("type:""" & strType & """,")
    sb.AppendLine("url:""" & strurl & """,")
    sb.AppendLine("data: { XmlPacket:""" & XMLString & """},")
    sb.AppendLine("contentType:""application/x-www-form-urlencoded"",")
    sb.AppendLine("dataType: ""xml"",")
    sb.AppendLine("success: function(data){ ")
    sb.AppendLine("alert(data);")
    sb.AppendLine("},")
    sb.AppendLine("error: function(error, message){")
    sb.AppendLine("alert('Error processing data. Please try again.');")
    sb.AppendLine("}")
    sb.AppendLine("});")
    sb.AppendLine("};")
    sb.AppendLine("POSTtoEP();")
    sb.AppendLine("</script>")
    Return sb.ToString()
End Function
公共共享函数POSTtoEP()为[String]
Dim strurl作为字符串=”https://www.executiveplacements.com/Job_Post_Xml.asp"
Dim strType As String=“POST”
使某人成为新的架线工
某人加上一行(“”)
sb.AppendLine(“函数POSTtoEP(){”)
sb.AppendLine($.ajax({”)
sb.AppendLine(“类型:”&strType&“,”)
sb.AppendLine(“url:”&strurl&“,”)
sb.AppendLine(“数据:{XmlPacket:”&XMLString&“}”)
sb.AppendLine(“contentType:”application/x-www-form-urlencoded“”)
sb.AppendLine(“数据类型:“xml”)
sb.AppendLine(“成功:函数(数据){”)
某人加上一行(“警报(数据);”)
某人附言(“},”)
sb.AppendLine(“错误:函数(错误,消息){”)
sb.AppendLine(“警报('处理数据时出错。请重试');”)
某人加上一行(“}”)
sb.附录(“};”)
某人追加(“};”)
某人附言(“POSTtoEP();”)
某人加上一行(“”)
把某人送回原处
端函数

此代码呈现正确的javascript。但是,如果Job_Post_Xml.asp未返回“application/x-www-form-urlencoded”,则需要修改ContentType。否则将产生解析错误。我相信Job_Post_Xml.asp有gzip编码,但不能在这里测试它,因为它是一个跨域请求。

那么这个输出的JavaScript代码最终是什么样子的呢?我已经将输出图像附加到问题上,看起来它应该会导致一些语法错误。。。对于初学者来说,它在多个地方遗漏了文本文本文本的引号。确切地说,如果它给了我一个错误,那会更好,因为我可以从那里着手解决它,但是这篇文章没有输出。有什么建议吗?好吧,建议您修复这些错误…那么这个输出的JavaScript代码最终是什么样子的呢?我已经将输出图像附加到问题上,看起来它应该会导致一些语法错误。。。对于初学者来说,它在多个地方遗漏了文本文本文本的引号。确切地说,如果它给了我一个错误,那会更好,因为我可以从那里着手解决它,但是这篇文章没有输出。有什么建议吗?好吧,建议你修正那些错误。。。