一个单机事件:
<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>

解决方案 »

  1.   

    你说productType_ShowProductType?pageModel.currentpage=5在地址上可以访问那么就没问题。
    你的alert("..."+value); 有没有弹出值呢?
    你使用URL传参,所以用GET就OK了。
    $.get(("productType_ShowProductType?pageModel.currentpage=5",function(data){alert(data)});PS:你访问的是productType类的ShowProductType方法,那么类的首字母要大写,方法首字母要小写。
      

  2.   

    alert("..."+value); 弹出来了。
    就算改成$.get("productType_showProductType?pageModel.currentpage=5",null,function(returnValue){
            });  也没反应! 控制台没有任何输出,也没有报错!求解释...
      

  3.   

    你要的反應應該都在returnValue里了吧?
      

  4.   

    都没有到Action里面去,showProductType 方法没有进去....
      

  5.   

    我不熟悉jquery,沒有進去,那是get方法的第一個參數寫的有問題吧,就像1樓說的,或者其它什麽問題
    productType_showProductType?pageModel.currentpage=5
      

  6.   

    但是productType_showProductType?pageModel.currentpage=5 浏览器中可以进去...求高手!
      

  7.   

    把地址写错全路劲试试吧。
    如果地址没有错的话,会不会是浏览器缓存?
    给地址加个随机数试试$.post("productType_ShowProductType?pageModel.currentpage=5&t="+new Date().getTime(),null,function(returnValue){
        //.....
    });
      

  8.   

    恩。对,你的这个参数能不能这么写是个问题啊,你在action里面输出下这个值看拿到没有啊,这个我觉得肯定就是写法有点问题。pageModel.currentpage~~
      

  9.   

     就算不带参数过去也是一样的,都没有到Action的方法中去,似乎没有执行这个异步操作。
     使用超链接却可以进去.<a href="productType_showProductType?pageModel.currentpage=3">代号</a>  这个链接可以进去,和上面一样的。 我不知道是不是我的json配置有错还是怎么了?求高手!谢谢~~
      

  10.   

    看看這裡的用法,我覺得lz的用法還是有些出入的。Examples:
    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/
      

  11.   

    $.ajax({
       type: "POST",
       url: "productType_showProductType",
                               data:"pageModel.currentpage=5",
       dataType :"json",
       success: function(returnValue){
            alert(returnValue);
       }
    });