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 ,时最好是加上空第二个参数,没有也要用 {}

你可能感兴趣的:(html,jquery,Ajax,json,xml)