jquery post 方法不适用于 jax-rs Web 服务

发布于 2024-10-24 04:00:13 字数 1015 浏览 5 评论 0原文

当我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温馨耳语 2024-10-31 04:00:13

我建议放置 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文