jquery页面传值问题 'Upload.aspx?param1='+$("#txtbanbenhao").val()+'¶m2='+$("#txtgonghao").val()为什么在获取不到param2的值,只能获取param1的值啊。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $("#txtgonghao").val() 有值吗 ?你这样 应该是没问题的 。 有值啊,我也纳闷呢,同样的写法,为什么param1能取到值,param2却不行。 alert($("#txtgonghao").val());如果他有值那么你就看一下php的部分param2的取值部分.或者firebug看一下传递状况 以下是我的代码:Default.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> <link rel="Stylesheet" href="js/uploadify.css" /> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/swfobject.js"></script> <script type="text/javascript" src="js/jquery.uploadify.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#uploadify").uploadify({ 'uploader': 'js/uploadify.swf', 'script': 'Upload.aspx?param2='+$("#txtbanbenhao").val()+'¶m1='+$("#txtgonghao").val(), 'cancelImg': 'js/cancel.png', 'folder': 'upload', 'queueID': 'fileQueue', 'auto': false, 'multi': true, }); }); </script></head><body> <form id="form1" runat="server" > <input type="file" name="uploadify" id="uploadify" /> <a href="javascript:$('#uploadify').uploadifyUpload()">上传</a>| <a href="javascript:$('#uploadify').uploadifyClearQueue()"> 取消上传</a> <div id="fileQueue"> <asp:TextBox ID="txtgonghao" runat="server"></asp:TextBox> <asp:TextBox ID="txtbanbenhao" runat="server"></asp:TextBox> </div> </form></body></html>Upload.aspx页面<asp:TextBox ID="txtgonghao" runat="server"></asp:TextBox> <asp:TextBox ID="txtbanbenhao" runat="server"></asp:TextBox>Upload.aspx.cs 代码using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.IO; public partial class Upload : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { string param1 = Request.QueryString["param1"]; string param2 = Request.QueryString["param2"]; this.txtgonghao.Text = param1; this.txtbanbenhao.Text = param2; string path = Server.MapPath("files/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } HttpFileCollection files = Request.Files; string fileName = string.Empty; for (int i = 0; i < files.Count; i++) { fileName = Path.GetFileName(files[i].FileName).ToLower(); files[i].SaveAs(path + fileName); } }} alert($("#txtgonghao").val());有值。firebug 这是什么 firebug是火狐的一个插件 用来调试js很好用.console.log("ddd")乃火狐神器,避免了烦人的alert 你在upload.aspx.cs 里面 打印 Response.Write(Request.QueryString.ToString()); 看有没有传过来,如果没有就是插件的问题 uploadifyID=uploadify&pagepath=/WebSite2/&script=Upload.aspx?param1=1¶m2=2&folder=upload&width=110&height=30&wmode=opaque&method=POST&queueSizeLimit=999&simUploadLimit=1&multi=true&fileDataName=Filedata&queueID=fileQueue我用firebug调试的时候发现param1=1 和 param2=2 的值是传过来了,但是是不是写法有问题啊。Upload.aspx?param1=1¶m2=2 是不是因为这么写的时候把param2的值没有当成参数传过去。 "&" 在JavaScript解析为变量连接符,所以服务器端接收数据时&符号以后的数据都会丢失。是不是这个原因造成我的param2的参数没有传递过来。如果是这种情况,该如何解决。 试一下用scriptData传值'scriptData' : ({'var_name': 'this_var_value'}), 这种传值方式我不会,不过我知道是什么原因造成param2的值传不过去了,是因为&造成的,丢失参数,我解析了一下变量符& ,解决方法http://hi.baidu.com/aboc/blog/item/1bc73ac7207c58d7d1006031.html 我发现了是因为在传值的时候&连接符没有解析,解决方法 replace(/\&/g, "%26") js图片预加载 能否只获取某个网页里的视频资源 遇到这样一个问题? JS获取复选框 JQuery(Javascript)动态隐藏table的多个列怎么实现? 请问有没有什么方法可以修改提示框的样式? 如何用javascript在页面中动态更新某一块的内容? 监听当前页面某一部分超链接单击事件,事件触发后传一个值给当前超链接url,怎样实现? 求一个无错JS时间控件 静态html在vs2010中现在不能加ActiveX控件了吗? Html如何使用ExtJs 【高分】请教这段代码怎么写?
有值吗 ?
你这样 应该是没问题的 。
有值啊,我也纳闷呢,同样的写法,为什么param1能取到值,param2却不行。
如果他有值那么你就看一下php的部分param2的取值部分.
或者firebug看一下传递状况
Default.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="Stylesheet" href="js/uploadify.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript" src="js/jquery.uploadify.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#uploadify").uploadify({
'uploader': 'js/uploadify.swf',
'script': 'Upload.aspx?param2='+$("#txtbanbenhao").val()+'¶m1='+$("#txtgonghao").val(),
'cancelImg': 'js/cancel.png',
'folder': 'upload',
'queueID': 'fileQueue',
'auto': false,
'multi': true,
});
});
</script>
</head>
<body>
<form id="form1" runat="server" >
<input type="file" name="uploadify" id="uploadify" />
<a href="javascript:$('#uploadify').uploadifyUpload()">上传</a>| <a href="javascript:$('#uploadify').uploadifyClearQueue()"> 取消上传</a>
<div id="fileQueue">
<asp:TextBox ID="txtgonghao" runat="server"></asp:TextBox>
<asp:TextBox ID="txtbanbenhao" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
Upload.aspx页面
<asp:TextBox ID="txtgonghao" runat="server"></asp:TextBox>
<asp:TextBox ID="txtbanbenhao" runat="server"></asp:TextBox>
Upload.aspx.cs 代码
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO; public partial class Upload : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string param1 = Request.QueryString["param1"];
string param2 = Request.QueryString["param2"];
this.txtgonghao.Text = param1;
this.txtbanbenhao.Text = param2;
string path = Server.MapPath("files/");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
HttpFileCollection files = Request.Files;
string fileName = string.Empty;
for (int i = 0; i < files.Count; i++)
{
fileName = Path.GetFileName(files[i].FileName).ToLower();
files[i].SaveAs(path + fileName);
}
}
}
alert($("#txtgonghao").val());有值。
firebug 这是什么
'scriptData' : ({'var_name': 'this_var_value'}),
这种传值方式我不会,不过我知道是什么原因造成param2的值传不过去了,是因为&造成的,丢失参数,我解析了一下变量符& ,解决方法http://hi.baidu.com/aboc/blog/item/1bc73ac7207c58d7d1006031.html