ajax jsonp只执行error方法,不执行success方法如何处理?

js代码:

var base = {
urlHead : "http://localhost:8080/CreditWorld/"
}
var user = {
login : function (){
$.ajax({
cache: true,
type: "POST",
url:base.urlHead+"userRegist",
data:$('#userRegistForm').serialize(),//
//data:"{}",
async: false,
dataType:"jsonp",
//jsonp:'callback',
jsonpCallback: "back",
success: function(data) {
alert("success" + data)
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest);
}

    });
    }
}


服务器代码:
public String userRegist() {
    result = callback+"({\"flag\":\"successfuly\"})";//返回必须是json字符串;
    System.out.println(result);
    return SUCCESS;
}


xml配置

<package name="json" extends="json-default" namespace="/">      
    <action name="userRegist" class="com.credit.action.RegistAction" method="userRegist"> 
        <result name="success" type="json">
            <param name="root">result</param>
        </result>
    </action>
</package>


开发者工具查到的返回值
![图片说明](https://img-ask.csdn.net/upload/201608/07/1470560155_895335.png)
查看全部
qq_31655965
Sharember
2016/08/07 08:56
  • 点赞
  • 收藏
  • 回答
    私信

3个回复