我正在尝试提交使用JQuery创建的表单。但是,调用JQuery的.submit()
方法会将我发送到具有正确URL的空白页面。手动前往创建的URL可以正常工作。
详细说明:
我有一些代码可以创建一个非常大的表单对象,它不会插入到页面的任何位置(javascript是通过coffeescript生成的,如果这有所不同的话)。代码从(私人)页面http://webzyme-devl.umms.med.umich.edu:8080/webMathematica/webZyme/create.jsp
调用form = $("<form action='" + (window.location.protocol + '//' + window.location.host + window.location.pathname) + "' method='GET'>");
addField = function(name) {
return form.append("<input type='text' name='" + name + "' value='" + ($("#" + name).val()) + "'>");
};
addCheckbox = function(name) {
var el;
el = $("<input type='checkbox' name='" + name + "'>");
el.prop("checked", $("#" + name).prop("checked"));
return form.append(el);
};
addNewCheckbox = function(name) {
var el;
el = $("<input type='checkbox' name='" + name + "'>");
el.prop("checked", true);
return form.append(el);
};
//This is followed by a a bunch of processing and
// calls to addField, addCheckbox, addNewCheckbox, and manual calls to form.append
//No other modifications are made to the form, and no events are assigned to it
根据Chrome和Firefox调试程序给出了以下表单(为了调试我已将表单设置为GET,尽管它实际上是POST):
<form method="GET" action="http://webzyme-devl.umms.med.umich.edu:8080/webMathematica/webZyme/create.jsp">
<input type="text" value="create" name="submitType">
<input type="text" value="assign" name="createType">
<input type="checkbox" name="repopulate">
<input type="text" value="Default" name="createClassName">
<input type="text" value=" kid10" name="createStudentName">
<input type="text" value="Test Prob" name="createProblemTitle">
<input type="text" value="445" name="createProblemNumber">
<input type="text" value="A Problem_Problemy" name="createProblemDesc">
<input type="text" value="NoteNoteNote" name="createProblemTeacherNotes">
<input type="text" value="Not a note, unless its a note & notes^ are excellent" name="createProblemStudentNotes">
<input type="checkbox" name="sfOnOff">
<input type="checkbox" name="fluorOnOff">
<input type="checkbox" name="quenchOnOff">
<input type="checkbox" name="ssOnOff">
<input type="text" value="Eox+DHO<>RS" name="reaction0info">
<input type="text" value="1E7" name="reaction0kfwd">
<input type="text" value="2000E0" name="reaction0krev">
<input type="text" value="RS>CT" name="reaction1info">
<input type="text" value="160E0" name="reaction1kfwd">
<input type="text" value="" name="reaction1krev">
<input type="text" value="CT<>Ered+OA" name="reaction2info">
<input type="text" value="25E0" name="reaction2kfwd">
<input type="text" value="1E5" name="reaction2krev">
<input type="text" value="Ered+Fum<>EredFum" name="reaction3info">
<input type="text" value="1E6" name="reaction3kfwd">
<input type="text" value="2000E0" name="reaction3krev">
<input type="text" value="EredFum>EoxSuc" name="reaction4info">
<input type="text" value="20E0" name="reaction4kfwd">
<input type="text" value="" name="reaction4krev">
<input type="text" value="EoxSuc<>Eox+Suc" name="reaction5info">
<input type="text" value="1000E0" name="reaction5kfwd">
<input type="text" value="1E5" name="reaction5krev">
<input type="text" value="" name="reaction6info">
<input type="text" value="" name="reaction6kfwd">
<input type="text" value="" name="reaction6krev">
<input type="text" value="" name="reaction7info">
<input type="text" value="" name="reaction7kfwd">
<input type="text" value="" name="reaction7krev">
<input type="text" value="" name="reaction8info">
<input type="text" value="" name="reaction8kfwd">
<input type="text" value="" name="reaction8krev">
<input type="text" value="" name="reaction9info">
<input type="text" value="" name="reaction9kfwd">
<input type="text" value="" name="reaction9krev">
<input type="text" value="" name="reaction10info">
<input type="text" value="" name="reaction10kfwd">
<input type="text" value="" name="reaction10krev">
<input type="text" value="" name="reaction11info">
<input type="text" value="" name="reaction11kfwd">
<input type="text" value="" name="reaction11krev">
<input type="text" value="DHO,Eox,Ered,Fum,OA,Suc" name="ICSpecies">
<input type="text" value="300" name="Wavelength1">
<input type="text" value="700" name="Wavelength2">
<input type="text" value="0.001" name="SFNoise">
<input type="text" value="Eox,EoxSuc" name="Spec0">
<input type="text" value="2.E4" name="Spec0mu0">
<input type="text" value="2700" name="Spec0omega0">
<input type="text" value="1.5E3" name="Spec0sigma0">
<input type="text" value="9.E3" name="Spec0mu1">
<input type="text" value="3.65E2" name="Spec0omega1">
<input type="text" value="1.E3" name="Spec0sigma1">
<input type="text" value="1.1E4" name="Spec0mu2">
<input type="text" value="4.55E2" name="Spec0omega2">
<input type="text" value="1.1E3" name="Spec0sigma2">
<input type="text" value="" name="Spec0mu3">
<input type="text" value="" name="Spec0omega3">
<input type="text" value="" name="Spec0sigma3">
<input type="text" value="Ered,EredFum" name="Spec1">
<input type="text" value="2.5E4" name="Spec1mu0">
<input type="text" value="2.65E2" name="Spec1omega0">
<input type="text" value="1.5E3" name="Spec1sigma0">
<input type="text" value="4.E3" name="Spec1mu1">
<input type="text" value="3.55E2" name="Spec1omega1">
<input type="text" value="1.8E3" name="Spec1sigma1">
<input type="text" value="" name="Spec1mu2">
<input type="text" value="" name="Spec1omega2">
<input type="text" value="" name="Spec1sigma2">
<input type="text" value="" name="Spec1mu3">
<input type="text" value="" name="Spec1omega3">
<input type="text" value="" name="Spec1sigma3">
<input type="text" value="CT" name="Spec2">
<input type="text" value="2.5E4" name="Spec2mu0">
<input type="text" value="2.75E2" name="Spec2omega0">
<input type="text" value="1.5E3" name="Spec2sigma0">
<input type="text" value="3.7E3" name="Spec2mu1">
<input type="text" value="3.6E2" name="Spec2omega1">
<input type="text" value="1.9E3" name="Spec2sigma1">
<input type="text" value="" name="Spec2mu2">
<input type="text" value="" name="Spec2omega2">
<input type="text" value="" name="Spec2sigma2">
<input type="text" value="" name="Spec2mu3">
<input type="text" value="" name="Spec2omega3">
<input type="text" value="" name="Spec2sigma3">
<input type="text" value="RS" name="Spec3">
<input type="text" value="2.E4" name="Spec3mu0">
<input type="text" value="2.75E2" name="Spec3omega0">
<input type="text" value="1.5E3" name="Spec3sigma0">
<input type="text" value="" name="Spec3mu1">
<input type="text" value="" name="Spec3omega1">
<input type="text" value="" name="Spec3sigma1">
<input type="text" value="" name="Spec3mu2">
<input type="text" value="" name="Spec3omega2">
<input type="text" value="" name="Spec3sigma2">
<input type="text" value="" name="Spec3mu3">
<input type="text" value="" name="Spec3omega3">
<input type="text" value="" name="Spec3sigma3">
<input type="text" value="" name="Spec4">
<input type="text" value="" name="Spec4mu0">
<input type="text" value="" name="Spec4omega0">
<input type="text" value="" name="Spec4sigma0">
<input type="text" value="" name="Spec4mu1">
<input type="text" value="" name="Spec4omega1">
<input type="text" value="" name="Spec4sigma1">
<input type="text" value="" name="Spec4mu2">
<input type="text" value="" name="Spec4omega2">
<input type="text" value="" name="Spec4sigma2">
<input type="text" value="" name="Spec4mu3">
<input type="text" value="" name="Spec4omega3">
<input type="text" value="" name="Spec4sigma3">
<input type="text" value="" name="Spec5">
<input type="text" value="" name="Spec5mu0">
<input type="text" value="" name="Spec5omega0">
<input type="text" value="" name="Spec5sigma0">
<input type="text" value="" name="Spec5mu1">
<input type="text" value="" name="Spec5omega1">
<input type="text" value="" name="Spec5sigma1">
<input type="text" value="" name="Spec5mu2">
<input type="text" value="" name="Spec5omega2">
<input type="text" value="" name="Spec5sigma2">
<input type="text" value="" name="Spec5mu3">
<input type="text" value="" name="Spec5omega3">
<input type="text" value="" name="Spec5sigma3">
<input type="text" value="" name="Spec6">
<input type="text" value="" name="Spec6mu0">
<input type="text" value="" name="Spec6omega0">
<input type="text" value="" name="Spec6sigma0">
<input type="text" value="" name="Spec6mu1">
<input type="text" value="" name="Spec6omega1">
<input type="text" value="" name="Spec6sigma1">
<input type="text" value="" name="Spec6mu2">
<input type="text" value="" name="Spec6omega2">
<input type="text" value="" name="Spec6sigma2">
<input type="text" value="" name="Spec6mu3">
<input type="text" value="" name="Spec6omega3">
<input type="text" value="" name="Spec6sigma3">
<input type="text" value="" name="Spec7">
<input type="text" value="" name="Spec7mu0">
<input type="text" value="" name="Spec7omega0">
<input type="text" value="" name="Spec7sigma0">
<input type="text" value="" name="Spec7mu1">
<input type="text" value="" name="Spec7omega1">
<input type="text" value="" name="Spec7sigma1">
<input type="text" value="" name="Spec7mu2">
<input type="text" value="" name="Spec7omega2">
<input type="text" value="" name="Spec7sigma2">
<input type="text" value="" name="Spec7mu3">
<input type="text" value="" name="Spec7omega3">
<input type="text" value="" name="Spec7sigma3">
<input type="text" value="" name="Spec8">
<input type="text" value="" name="Spec8mu0">
<input type="text" value="" name="Spec8omega0">
<input type="text" value="" name="Spec8sigma0">
<input type="text" value="" name="Spec8mu1">
<input type="text" value="" name="Spec8omega1">
<input type="text" value="" name="Spec8sigma1">
<input type="text" value="" name="Spec8mu2">
<input type="text" value="" name="Spec8omega2">
<input type="text" value="" name="Spec8sigma2">
<input type="text" value="" name="Spec8mu3">
<input type="text" value="" name="Spec8omega3">
<input type="text" value="" name="Spec8sigma3">
<input type="text" value="" name="Spec9">
<input type="text" value="" name="Spec9mu0">
<input type="text" value="" name="Spec9omega0">
<input type="text" value="" name="Spec9sigma0">
<input type="text" value="" name="Spec9mu1">
<input type="text" value="" name="Spec9omega1">
<input type="text" value="" name="Spec9sigma1">
<input type="text" value="" name="Spec9mu2">
<input type="text" value="" name="Spec9omega2">
<input type="text" value="" name="Spec9sigma2">
<input type="text" value="" name="Spec9mu3">
<input type="text" value="" name="Spec9omega3">
<input type="text" value="" name="Spec9sigma3">
<input type="text" value="400" name="EWavelength1">
<input type="text" value="700" name="EWavelength2">
<input type="text" value="1" name="FluorNoise">
<input type="text" value="1000" name="FluorMax">
<input type="checkbox" name="IFEEnable">
<input type="text" value="" name="IFEx">
<input type="text" value="" name="IFEy">
<input type="text" value="Eox" name="ESpec0">
<input type="text" value="1.E2" name="ESpec0mu0">
<input type="text" value="5.25E2" name="ESpec0omega0">
<input type="text" value="1.E3" name="ESpec0sigma0">
<input type="text" value="" name="ESpec0mu1">
<input type="text" value="" name="ESpec0omega1">
<input type="text" value="" name="ESpec0sigma1">
<input type="text" value="" name="ESpec0mu2">
<input type="text" value="" name="ESpec0omega2">
<input type="text" value="" name="ESpec0sigma2">
<input type="text" value="" name="ESpec1">
<input type="text" value="" name="ESpec1mu0">
<input type="text" value="" name="ESpec1omega0">
<input type="text" value="" name="ESpec1sigma0">
<input type="text" value="" name="ESpec1mu1">
<input type="text" value="" name="ESpec1omega1">
<input type="text" value="" name="ESpec1sigma1">
<input type="text" value="" name="ESpec1mu2">
<input type="text" value="" name="ESpec1omega2">
<input type="text" value="" name="ESpec1sigma2">
<input type="text" value="" name="ESpec2">
<input type="text" value="" name="ESpec2mu0">
<input type="text" value="" name="ESpec2omega0">
<input type="text" value="" name="ESpec2sigma0">
<input type="text" value="" name="ESpec2mu1">
<input type="text" value="" name="ESpec2omega1">
<input type="text" value="" name="ESpec2sigma1">
<input type="text" value="" name="ESpec2mu2">
<input type="text" value="" name="ESpec2omega2">
<input type="text" value="" name="ESpec2sigma2">
<input type="text" value="" name="ESpec3">
<input type="text" value="" name="ESpec3mu0">
<input type="text" value="" name="ESpec3omega0">
<input type="text" value="" name="ESpec3sigma0">
<input type="text" value="" name="ESpec3mu1">
<input type="text" value="" name="ESpec3omega1">
<input type="text" value="" name="ESpec3sigma1">
<input type="text" value="" name="ESpec3mu2">
<input type="text" value="" name="ESpec3omega2">
<input type="text" value="" name="ESpec3sigma2">
<input type="text" value="" name="ESpec4">
<input type="text" value="" name="ESpec4mu0">
<input type="text" value="" name="ESpec4omega0">
<input type="text" value="" name="ESpec4sigma0">
<input type="text" value="" name="ESpec4mu1">
<input type="text" value="" name="ESpec4omega1">
<input type="text" value="" name="ESpec4sigma1">
<input type="text" value="" name="ESpec4mu2">
<input type="text" value="" name="ESpec4omega2">
<input type="text" value="" name="ESpec4sigma2">
<input type="text" value="" name="ESpec5">
<input type="text" value="" name="ESpec5mu0">
<input type="text" value="" name="ESpec5omega0">
<input type="text" value="" name="ESpec5sigma0">
<input type="text" value="" name="ESpec5mu1">
<input type="text" value="" name="ESpec5omega1">
<input type="text" value="" name="ESpec5sigma1">
<input type="text" value="" name="ESpec5mu2">
<input type="text" value="" name="ESpec5omega2">
<input type="text" value="" name="ESpec5sigma2">
<input type="text" value="2%" name="QNoise">
<input type="text" value="OA+CT" name="ASpecs0">
<input type="text" value="Total Orotate" name="ASpecs0ID">
<input type="text" value="EoxSuc+Suc" name="ASpecs1">
<input type="text" value="Total Succinate" name="ASpecs1ID">
<input type="text" value="" name="ASpecs2">
<input type="text" value="" name="ASpecs2ID">
<input type="text" value="" name="ASpecs3">
<input type="text" value="" name="ASpecs3ID">
<input type="text" value="" name="ASpecs4">
<input type="text" value="" name="ASpecs4ID">
<input type="text" value="" name="ASpecs5">
<input type="text" value="" name="ASpecs5ID">
<input type="text" value="" name="ASpecs6">
<input type="text" value="" name="ASpecs6ID">
<input type="text" value="" name="ASpecs7">
<input type="text" value="" name="ASpecs7ID">
<input type="text" value="" name="ASpecs8">
<input type="text" value="" name="ASpecs8ID">
<input type="text" value="2%" name="SSNoise">
<input type="text" value="Suc" name="VoI">
<input type="text" value="Eox,Ered" name="enzymeNames">
<input type="text" value="Eox,RS,CT,Ered,EredFum,EoxSuc" name="conservation">
</form>
然后我尝试提交表单:
form.submit()
我希望这会在表单生成的主页面中加载URL。它确实将地址栏中的值设置为正确的URL
http://webzyme-devl.umms.med.umich.edu:8080/webMathematica/webZyme/create.jsp?submitType=create&createType=assign&repopulate=on&createClassName=Default&createStudentName=+kid10&createProblemTitle=Test+Prob&createProblemNumber=445&createProblemDesc=A+Problem_Problemy&createProblemTeacherNotes=NoteNoteNote&createProblemStudentNotes=Not+a+note%2C+unless+its+a+note+%26+notes%5E+are+excellent&sfOnOff=on&fluorOnOff=on&quenchOnOff=on&ssOnOff=on&reaction0info=Eox%2BDHO%3C%3ERS&reaction0kfwd=1E7&reaction0krev=2000E0&reaction1info=RS%3ECT&reaction1kfwd=160E0&reaction1krev=&reaction2info=CT%3C%3EEred%2BOA&reaction2kfwd=25E0&reaction2krev=1E5&reaction3info=Ered%2BFum%3C%3EEredFum&reaction3kfwd=1E6&reaction3krev=2000E0&reaction4info=EredFum%3EEoxSuc&reaction4kfwd=20E0&reaction4krev=&reaction5info=EoxSuc%3C%3EEox%2BSuc&reaction5kfwd=1000E0&reaction5krev=1E5&reaction6info=&reaction6kfwd=&reaction6krev=&reaction7info=&reaction7kfwd=&reaction7krev=&reaction8info=&reaction8kfwd=&reaction8krev=&reaction9info=&reaction9kfwd=&reaction9krev=&reaction10info=&reaction10kfwd=&reaction10krev=&reaction11info=&reaction11kfwd=&reaction11krev=&ICSpecies=DHO%2CEox%2CEred%2CFum%2COA%2CSuc&Wavelength1=300&Wavelength2=700&SFNoise=0.001&Spec0=Eox%2CEoxSuc&Spec0mu0=2.E4&Spec0omega0=2700&Spec0sigma0=1.5E3&Spec0mu1=9.E3&Spec0omega1=3.65E2&Spec0sigma1=1.E3&Spec0mu2=1.1E4&Spec0omega2=4.55E2&Spec0sigma2=1.1E3&Spec0mu3=&Spec0omega3=&Spec0sigma3=&Spec1=Ered%2CEredFum&Spec1mu0=2.5E4&Spec1omega0=2.65E2&Spec1sigma0=1.5E3&Spec1mu1=4.E3&Spec1omega1=3.55E2&Spec1sigma1=1.8E3&Spec1mu2=&Spec1omega2=&Spec1sigma2=&Spec1mu3=&Spec1omega3=&Spec1sigma3=&Spec2=CT&Spec2mu0=2.5E4&Spec2omega0=2.75E2&Spec2sigma0=1.5E3&Spec2mu1=3.7E3&Spec2omega1=3.6E2&Spec2sigma1=1.9E3&Spec2mu2=&Spec2omega2=&Spec2sigma2=&Spec2mu3=&Spec2omega3=&Spec2sigma3=&Spec3=RS&Spec3mu0=2.E4&Spec3omega0=2.75E2&Spec3sigma0=1.5E3&Spec3mu1=&Spec3omega1=&Spec3sigma1=&Spec3mu2=&Spec3omega2=&Spec3sigma2=&Spec3mu3=&Spec3omega3=&Spec3sigma3=&Spec4=&Spec4mu0=&Spec4omega0=&Spec4sigma0=&Spec4mu1=&Spec4omega1=&Spec4sigma1=&Spec4mu2=&Spec4omega2=&Spec4sigma2=&Spec4mu3=&Spec4omega3=&Spec4sigma3=&Spec5=&Spec5mu0=&Spec5omega0=&Spec5sigma0=&Spec5mu1=&Spec5omega1=&Spec5sigma1=&Spec5mu2=&Spec5omega2=&Spec5sigma2=&Spec5mu3=&Spec5omega3=&Spec5sigma3=&Spec6=&Spec6mu0=&Spec6omega0=&Spec6sigma0=&Spec6mu1=&Spec6omega1=&Spec6sigma1=&Spec6mu2=&Spec6omega2=&Spec6sigma2=&Spec6mu3=&Spec6omega3=&Spec6sigma3=&Spec7=&Spec7mu0=&Spec7omega0=&Spec7sigma0=&Spec7mu1=&Spec7omega1=&Spec7sigma1=&Spec7mu2=&Spec7omega2=&Spec7sigma2=&Spec7mu3=&Spec7omega3=&Spec7sigma3=&Spec8=&Spec8mu0=&Spec8omega0=&Spec8sigma0=&Spec8mu1=&Spec8omega1=&Spec8sigma1=&Spec8mu2=&Spec8omega2=&Spec8sigma2=&Spec8mu3=&Spec8omega3=&Spec8sigma3=&Spec9=&Spec9mu0=&Spec9omega0=&Spec9sigma0=&Spec9mu1=&Spec9omega1=&Spec9sigma1=&Spec9mu2=&Spec9omega2=&Spec9sigma2=&Spec9mu3=&Spec9omega3=&Spec9sigma3=&EWavelength1=400&EWavelength2=700&FluorNoise=1&FluorMax=1000&IFEx=&IFEy=&ESpec0=Eox&ESpec0mu0=1.E2&ESpec0omega0=5.25E2&ESpec0sigma0=1.E3&ESpec0mu1=&ESpec0omega1=&ESpec0sigma1=&ESpec0mu2=&ESpec0omega2=&ESpec0sigma2=&ESpec1=&ESpec1mu0=&ESpec1omega0=&ESpec1sigma0=&ESpec1mu1=&ESpec1omega1=&ESpec1sigma1=&ESpec1mu2=&ESpec1omega2=&ESpec1sigma2=&ESpec2=&ESpec2mu0=&ESpec2omega0=&ESpec2sigma0=&ESpec2mu1=&ESpec2omega1=&ESpec2sigma1=&ESpec2mu2=&ESpec2omega2=&ESpec2sigma2=&ESpec3=&ESpec3mu0=&ESpec3omega0=&ESpec3sigma0=&ESpec3mu1=&ESpec3omega1=&ESpec3sigma1=&ESpec3mu2=&ESpec3omega2=&ESpec3sigma2=&ESpec4=&ESpec4mu0=&ESpec4omega0=&ESpec4sigma0=&ESpec4mu1=&ESpec4omega1=&ESpec4sigma1=&ESpec4mu2=&ESpec4omega2=&ESpec4sigma2=&ESpec5=&ESpec5mu0=&ESpec5omega0=&ESpec5sigma0=&ESpec5mu1=&ESpec5omega1=&ESpec5sigma1=&ESpec5mu2=&ESpec5omega2=&ESpec5sigma2=&QNoise=2%25&ASpecs0=OA%2BCT&ASpecs0ID=Total+Orotate&ASpecs1=EoxSuc%2BSuc&ASpecs1ID=Total+Succinate&ASpecs2=&ASpecs2ID=&ASpecs3=&ASpecs3ID=&ASpecs4=&ASpecs4ID=&ASpecs5=&ASpecs5ID=&ASpecs6=&ASpecs6ID=&ASpecs7=&ASpecs7ID=&ASpecs8=&ASpecs8ID=&SSNoise=2%25&VoI=Suc&enzymeNames=Eox%2CEred&conservation=Eox%2CRS%2CCT%2CEred%2CEredFum%2CEoxSuc
但它只加载一个空页面,没有来自控制台的错误或指示已加载任何内容。但是,如果我直接前往URL(通过在地址栏中点击Return),请求将按预期发送并加载页面。我能够在多个浏览器中重复此行为
我的假设是,这是一个涉及我如何使用.submit()
方法的问题,而不是服务器配置的问题,因为手动提交URL会按预期工作。但是,如果它有所不同,该站点使用webMathematica在JavaServer上运行,并且当到达空页面时,服务器不会生成任何错误日志。
答案 0 :(得分:1)
看起来您正在使用get方法提交表单。我怀疑你的请求可能对get方法来说太长了,你可能会遇到一些客户端或服务器限制。
如果可能的话,我建议从GET切换到POST,以查看是否可以修复任何内容。还要检查您的Web服务器日志,看它是否可能抛出Request Too Long(414)错误。
如果您的get请求太长,有时字符串将被截断,这可能会导致目标脚本出错。
祝你好运。