一个单机事件:
<script type="text/javascript">
function pageChange(o){
var value=o.options[o.selectedIndex].id;
alert("..."+value);
$.post("productType_ShowProductType?pageModel.currentpage=5",null,function(returnValue){
});
}
</script>
productType_ShowProductType?pageModel.currentpage=5 这个在浏览器中可以访问到后台,在.post("productType_ShowProductType?pageModel.currentpage=5",null,function(returnValue){}); 却不行!?
引入了:struts2-json-plugin-2.1.8.1.jar
struts.xml
<package name="Pro" extends="json-default" >
<action name="*_*" class="{1}Action" method="{2}">
<result>/index.jsp</result>
</action>
</package>
<script type="text/javascript">
function pageChange(o){
var value=o.options[o.selectedIndex].id;
alert("..."+value);
$.post("productType_ShowProductType?pageModel.currentpage=5",null,function(returnValue){
});
}
</script>
productType_ShowProductType?pageModel.currentpage=5 这个在浏览器中可以访问到后台,在.post("productType_ShowProductType?pageModel.currentpage=5",null,function(returnValue){}); 却不行!?
引入了:struts2-json-plugin-2.1.8.1.jar
struts.xml
<package name="Pro" extends="json-default" >
<action name="*_*" class="{1}Action" method="{2}">
<result>/index.jsp</result>
</action>
</package>
你的alert("..."+value); 有没有弹出值呢?
你使用URL传参,所以用GET就OK了。
$.get(("productType_ShowProductType?pageModel.currentpage=5",function(data){alert(data)});PS:你访问的是productType类的ShowProductType方法,那么类的首字母要大写,方法首字母要小写。
就算改成$.get("productType_showProductType?pageModel.currentpage=5",null,function(returnValue){
}); 也没反应! 控制台没有任何输出,也没有报错!求解释...
productType_showProductType?pageModel.currentpage=5
如果地址没有错的话,会不会是浏览器缓存?
给地址加个随机数试试$.post("productType_ShowProductType?pageModel.currentpage=5&t="+new Date().getTime(),null,function(returnValue){
//.....
});
使用超链接却可以进去.<a href="productType_showProductType?pageModel.currentpage=3">代号</a> 这个链接可以进去,和上面一样的。 我不知道是不是我的json配置有错还是怎么了?求高手!谢谢~~
Example: Request the test.php page, but ignore the return results.$.get("test.php");Example: Request the test.php page and send some additional data along (while still ignoring the return results).$.get("test.php", { name: "John", time: "2pm" } );Example: pass arrays of data to the server (while still ignoring the return results).$.get("test.php", { 'choices[]': ["Jon", "Susan"]} );Example: Alert out the results from requesting test.php (HTML or XML, depending on what was returned).$.get("test.php", function(data){
alert("Data Loaded: " + data);
});Example: Alert out the results from requesting test.cgi with an additional payload of data (HTML or XML, depending on what was returned).$.get("test.cgi", { name: "John", time: "2pm" },
function(data){
alert("Data Loaded: " + data);
});Example: Gets the test.php page contents, which has been returned in json format (<?php echo json_encode(array("name"=>"John","time"=>"2pm")); ?>), and adds it to the page.$.get("test.php",
function(data){
$('body').append( "Name: " + data.name ) // John
.append( "Time: " + data.time ); // 2pm
}, "json");http://api.jquery.com/jQuery.get/
type: "POST",
url: "productType_showProductType",
data:"pageModel.currentpage=5",
dataType :"json",
success: function(returnValue){
alert(returnValue);
}
});