`

ofbiz中用ajax 注意点

阅读更多

1.

要想用 json 类型,可在 Controller .xml type="jsonjava" type="none" 返回数据放于 request

 

$jq.ajax({

                type:"POST",

                url:"<@ofbizUrl>"+u+"</@ofbizUrl>?productId=" + id + "&status="+status,

                dataType: "json",

                success: function(data) {

                    $jq('#p_'+id).html("("+data.status+")");

                }

        });

2.

不用 json 类型, aj ax 可以调用另一个 ftl screen, 其效果相当于局部的 submit

3.

$.post bug   jquery 中自己的实现。

 

post: function( url, data, callback, type ) {

if ( jQuery.isFunction( data ) ) {

callback = data;

data = {};

}

 

return jQuery.ajax({

type: "POST",

url: url,

data: data,

success: callback,

dataType: type

});

}

 

可以看出,如果 data 不写的话 if 就不会执行, return 时, data 就会为空 .

所有在用 post ,时最好是加上空第二个参数,没有也要用 {}

分享到:
评论
1 楼 ty88 2012-12-10  
楼主,请教下controller是定义的,java类型里面怎么返回的?我调试时通过ajax提交总是走到ControllerServlet的doRequest时就报错了。

相关推荐

Global site tag (gtag.js) - Google Analytics