第一个问题:
异步请求
/**
* @description 异步请求函数* @param storeid
* @return
*/
这里我要提示自己的是:storeid要确定是个数值或字符串,而不是一个对象
alert("hello");
$.ajax({
type: "POST",
url: "checkstoreid.html",
data: "storeid="+storeid.value,
success: function(msg){
$("#storeName").html(msg);
}
});
}
java函数是如此写的:
public String checkstoreid(){
message = couponbackbiz.storeName(storeid);
inputStream = new ByteArrayInputStream(message.getBytes());
return "success";
}
在struts文件中要这样写:
<action name="hellostream" class="com.myapp.AppAction" method="ajaxtran">
<result type="stream">
<param name="contentType">text/html></param>
<param name="inputName">inputStream</param>
</result>
</action>
在jsp或html页面中:
<input type="text" id="txt" οnclick="javascript:storeidchg();"><span id="storeName"></span>
第二个问题:
js框中字符数控制
<textarea id="txt"> dfdfkj</textarea><span id= "info "> </span>
<script>
m = 100;
document.getElementById( "info ").innerText = m;
document.getElementById( "txt ").onkeyup = function()
{
document.getElementById( "info ").innerText = m-document.getElementById( "txt ").value.length;
}
</script>