jQuery升级和AJAX

| 我刚刚从1.4升级到JQuery 1.5.2,而PostForm现在无法正常工作。它确实会发布到页面,但是即使没有错误也表示存在错误。
function TestPostForm(){
               $.ajax({
                    type: \"POST\",
                    url: \"process.jsp\",
                    data: \'operation=Test&ui=TestUser\',
                    dataType: \"application/x-www-form-urlencoded\",
                    async: false,
                    success: function(response) {
                        alert(\'Success\');
                        return response;                    
                     },
                         error: function(xhr, ajaxOptions, thrownError) {
                              alert(\"There was an error : \" + xhr.status);
                       }
                    });
              } 
Java代码:process.jsp
if (operation.equals(\"Test\")) {
            String ui = request.getParameter(\"ui\");
            out.println(\"Ok\" + ui);
        }
已邀请:
您的问题出在
dataType
,您应该定义的是
contentTypeString
contentType: \"application/x-www-form-urlencoded\"
dataType
定义您希望脚本返回的数据类型(xml,json,脚本或html),而
contentType
传递您在请求中发送的内容类型。 您可以在jQuery API上阅读有关这些选项的更多信息:http://api.jquery.com/jQuery.ajax/
为什么不这样发送数据?
data: {\'operation\': \'Test\', \'ui\': \'TestUser\'}
无需显式指定
dataType
使用Firebug嗅探您的AJAX活动,并查看服务器上正在生成什么错误。这可能会给您一个线索。

要回复问题请先登录注册