日期:2014-05-16  浏览次数:20724 次

js传叁时 url参数过长导致被截掉了.因为是get提交方式
代码如下:
 function showEmpDetailed(cmp,isAll,field,value){

var moreSQL = document.getElementById("moreSQL").value;
var url ='DetailedAction.do?isAll='+isAll+'&org='+cmp+'&field='+field+'&moreSQL='+moreSQL;
//alert(url)
if( value > 0 ){
var width = 1000;
var height = 600;
var left;
var top;
left=(window.screen.availWidth-width)/2;
top=(window.screen.availHeight-height)/2;
window.open( url , null,'left='+left+',top='+(top-100)+',width='+width+',height='+height+'status=yes,toolbar=no,menubar=no,resizable=yes,location=no');
}
}


上面代码moreSQL的值会很长很长、我现在传过去取来 一般都拿不到。现在我想问问大家有没好的建议。
我想要实际的实现代码.而不是说一句留言说:改成post提交。 如果是改成post提交 该怎么改。或者用其他方式传这个参数,该怎么写。。。求指教 、

------解决方案--------------------
If you wanted to use post to submit the request, you need to use the XMLHttpRequest (Ajax) or form element, for an example:

1. Use the Ajax to do the post:

jQuery.post("url", callback, {pars});

2. Use the form element do the post:

var form = document.createElement("form");
form.action = "url";
form.method = "post";

Here you can create some input elements to store the values, like the input box, check box and etc..

form.submit();

document.body.appendChild(form);
------解决方案--------------------
1要用post来提交,数据量比get传输的大

可以用form表交 method是post

2.可以用jquery ajax来提交 具体可以看下jquery api(chm手册)网上搜索下就有
类似下面这样,可以试下

JScript code

function showEmpDetailed(cmp,isAll,field,value){
    jQuery.ajax({    
        url:'DetailedAction.do',   //提交的url
        type:'POST',       // 使用post提交
        data:{isAll_val:isAll,org_val:cmp,field_val:field,password:jQuery('#moreSQL').val()},      //提交表单数据
        success:function(data){
              //回调函数处理
            #jQuery('#login_result').html(data);


            }

    });


    if( value > 0 ){
        var width = 1000;
        var height = 600;
        var left;
        var top;
        left=(window.screen.availWidth-width)/2;
        top=(window.screen.availHeight-height)/2;
        window.open( url , null,'left='+left+',top='+(top-100)+',width='+width+',height='+height+'status=yes,toolbar=no,menubar=no,resizable=yes,location=no');
    }
}

------解决方案--------------------
探讨
1要用post来提交,数据量比get传输的大

可以用form表交 method是post

2.可以用jquery ajax来提交 具体可以看下jquery api(chm手册)网上搜索下就有
类似下面这样,可以试下


JScript code


function showEmpDetailed(cmp,isAll,field,value){
jQuery……