jquery post 方法不适用于 jax-rs Web 服务
当我使用 jquery 发送此请求时:
<form id="myForm" action="http://myIp/../cat/create" method="post">
<fieldset>
<legend>jQuery.post Form Submit</legend>
Cat Id : <INPUT type="text" name="catId">
Cat Name: <INPUT type="text" name="catName">
<input type="submit" value="Submit" />
</fieldset>
</form>
脚本:
$(document).ready(function() {
$('#myForm').ajaxForm(function() {
alert("Thank you for your comment!");
});
});
JAX-RS(REST) 无法识别调用和打印以下消息的正确方法: 信息:系统在“My Class”类中找不到任何支持 OPTIONS 的方法。验证方法是否存在。
因此,当我不使用 jquery 而仅使用纯 HTML 执行相同操作时,一切都很好:
<FORM action="http://myaddress/../car/create" method="post">
<P>
Car Id : <INPUT type="text" name="carId">
Car Name: <INPUT type="text" name="carName"><
<INPUT type="submit" value="Send">
</P>
</FORM>
任何人都可以告诉我 jquery 做错了什么吗?
When I send this request using jquery:
<form id="myForm" action="http://myIp/../cat/create" method="post">
<fieldset>
<legend>jQuery.post Form Submit</legend>
Cat Id : <INPUT type="text" name="catId">
Cat Name: <INPUT type="text" name="catName">
<input type="submit" value="Submit" />
</fieldset>
</form>
The script:
$(document).ready(function() {
$('#myForm').ajaxForm(function() {
alert("Thank you for your comment!");
});
});
The JAX-RS(REST) cannot identify the correct method to call and print the following message:
INFO: The system cannot find any method in the "My Class" class that supports OPTIONS. Verify that a method exists.
Hence when I do the same without using jquery but with just plain HTML everything is fine:
<FORM action="http://myaddress/../car/create" method="post">
<P>
Car Id : <INPUT type="text" name="carId">
Car Name: <INPUT type="text" name="carName"><
<INPUT type="submit" value="Send">
</P>
</FORM>
Can anybody tell me what I'm doing wrong with jquery?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议放置 HTTP 代理(您可以使用 Fiddler2)并查看请求之间有什么区别。
该错误表明您的类不支持 OPTIONS。在 Fiddler 中,您可以查看是否确实发送了 OPTIONS 而不是 POST。
I suggest putting HTTP Proxy (you can use Fiddler2) and see what is the difference between the requests.
The error states that your class doesn't support OPTIONS. In Fiddler you can see if OPTIONS is really sent instead of POST.