[code=JScript]$.post("sealmaker.DrawArea",
{
action:redraw,
shape:shape,
color:sealcolor,
text:text,
style:textstyle,
size:textsize}
function(result)
{
alert(result);
}
);
[/code]
我是想把上面的几个参数传递到DrawArea类中的redraw方法中,但始终传不成功呢?
[quote] text : text, [/quote]
把text,里的逗号去掉,类似{action:redraw,shape:shape,color:sealcolor,text:text,style:textstyle,size:textsize}这种表示的最后一个后面是不需要加逗号的。你再试试。
你这用在哪里的,写的好奇怪,你看下jquery的api文档
data:your data;
可以使用:
$.post("demo_ajax_gethint.asp",{suggest:txt},function(result){
$("span").html(result);
});
或
$.ajax({
type: 'POST',
url: url,
data: data,
success: success,
dataType: dataType
});
[code="js"]
$.post("sealmaker.DrawArea",
{
data:"shape="+shape+"&color="+sealcolor+"&text="+text+"&style="+textstyle+"&size="+textsize
}
);
[/code]
[code="java"]
后台
String shape= request.getParameter("shape"); 这样获取数据、
[/code]
jQuery.post(url,[data],[callback]) ;post方法是这样子的,第一个参数是你的url,跟你form里的action类似的,比如你的xxx.do的请求路径或jsp页面的地址,。
另外你也可以按照如下方式用:
$.ajax({
type: "POST",
url: "some.php",
data: {action:redraw,shape:shape,color:sealcolor,text:text,style:textstyle,size:textsize},
success: function(msg){
alert( "Data Saved: " + msg );
});
[quote] text : text, [/quote]这个后面逗号去掉