ajax 对 struct 异步提交 标签的解决办法

问题:   struct 标签没有直接与ajax 数据兼容互换方法
解决: 先用struct 动态得到数据 ,再利用javascrpit 的 function(this) 把值提取 交给 ajax

需要提交的 struct link 项
< div2 >
         <html:link    onclick='return action(this)'                          //javascript 提交  参数为 自己标签 
                               action=""                                                       //屏蔽 struct 提交 但 用 struct 得到 动态值
                               paramName="tom"
                               paramProperty="personid"
                              paramId="personnelId">
                             编辑</html:link>
   <div2/>

< div1/ >

js 控制

            
function  action(obj) {
                
var str = obj.getAttribute('href');                  
                
var id = str.substring( str.lastIndexOf('=')+1, str.length );         // 取得 href 中的 的值 (由 struct 得到的 动态值 )
                   
var pars = 'do=edit&personnelId='+id;
                
new Ajax.Updater('div1','/rlzy/jcyy/basePersonnelList.do?',{parameters:pars,valScripts:true}); //由 prototype 的 ajax 异步提交
                Element.hide(document.getElementById(
"div2"));
                Element.show(document.getElementById(
"div1"));
                
                
return false;
            }


            
function  action2() {
                Element.hide(document.getElementById(
"div1"));
                Element.show(document.getElementById(
"div2"));
            }


        
</ SCRIPT >

rlzy
/ jcyy / basePersonnelList. do  的页面  就局部加入 页面 div1 了
<INPUT type='button' value="test" onclick="action2();"/>

感想:  javascript 万能胶水

你可能感兴趣的:(ajax 对 struct 异步提交 标签的解决办法)