java web service cannot capture post parameter from jquery post -
java web service cannot capture post parameter from jquery post -
client:
var info = "username=david"; $.post("/s/test", data, function(result) { alert(result); });
server:
@post @path("/test") @produces(mediatype.text_plain) public string test(@formparam("username") string username) { homecoming "your username " + username; }
the username null $formparam.
however, if post form:
<form method="post" action="/s/test"> <input type="text" name="username" value="david" /> <button type="submit">submit</button> </form>
the value can captured correct.
really don't know why.
new findings: happen jquery 2.1, 1.6 ok.
newer findings: utilize gf 3.1.2.2 solve issue well, however, gf 4 has issue.
java jquery ajax web-services
Comments
Post a Comment