且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ofbiz中用ajax 注意点

更新时间:2022-08-22 10:20:54

1.

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

 

$jq.ajax({

                type:"POST",

                url:""+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 ,时***是加上空第二个参数,没有也要用 {}