juery 和ajaxPro结合使用的有关问题,如内容
juery 和ajaxPro结合使用的问题,如内容
前台:
jQuery(document).ready(function($)
{
$("#div1").mouseover(function() {
alert('ddddddd');
});
$("#btnGetValue").click(function() {
var vUrl = $("#hUrl").val();
$.ajax(
{
type: "POST",
url: vUrl,
data: null,
beforeSend: function(xhr) {
xhr.setRequestHeader("ajaxpro-method", "HelloWorld");
},
success: function(s) {
alert(s);
var a = document.getElementById("div");
a.innerHTML= s;
}
});
});
});
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="tbReturnValue" runat="server" Width="232px"></asp:TextBox><br />
<input ID="btnGetValue" type="button" value="获取数据" style="width: 238px" />
<input id="hUrl" runat="server" type="hidden" />
<div id="div"></div>
</div>
</form>
</body>
后台:
AjaxPro.Utility.RegisterTypeForAjax(typeof(Default3));
if (!IsPostBack)
{
string path = "/WebSite1/ajaxpro/Default3,";
path += typeof(Default3).Assembly.FullName.Split(',')[0];
path += ".ashx";
hUrl.Value = path;
}
[AjaxPro.AjaxMethod]
public string HelloWorld()
{
return "<div id=div1>aaaa</div>";
}
上边有个div1鼠标滑过事件 这样从后台过来的滑过事件就不执行 为什么怎么才能执行 在线等
------解决思路----------------------
不是很明白楼主 在使用了 $.ajax的前提下还要使用 ajaxpro 是为什么
直接调用 Default3.HelloWorld().value 不能满足你的要求?
若要非得使用此方式 访问
$.ajax(
{
type: "POST",
url: vUrl,
beforeSend: function (xhr) {
xhr.setRequestHeader("Content-Type", "text/plain;charset=utf-8");
xhr.setRequestHeader("X-" + AjaxPro.ID + "-Method", "HelloWorld");
if (!MS.Browser.isIE) {
xhr.setRequestHeader("Connection", "close"); // Mozilla Bug #246651
}
},
success: function (s) {
alert(eval(s + "*" + "/"));
}
});
});
以上 支持 非ie 系列 ,ie系列请求楼主有兴趣的话就看 ajaxpro 中core.ashx等文件
中ajaxpro是如何构造 的 xmlhttp请求
前台:
jQuery(document).ready(function($)
{
$("#div1").mouseover(function() {
alert('ddddddd');
});
$("#btnGetValue").click(function() {
var vUrl = $("#hUrl").val();
$.ajax(
{
type: "POST",
url: vUrl,
data: null,
beforeSend: function(xhr) {
xhr.setRequestHeader("ajaxpro-method", "HelloWorld");
},
success: function(s) {
alert(s);
var a = document.getElementById("div");
a.innerHTML= s;
}
});
});
});
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="tbReturnValue" runat="server" Width="232px"></asp:TextBox><br />
<input ID="btnGetValue" type="button" value="获取数据" style="width: 238px" />
<input id="hUrl" runat="server" type="hidden" />
<div id="div"></div>
</div>
</form>
</body>
后台:
AjaxPro.Utility.RegisterTypeForAjax(typeof(Default3));
if (!IsPostBack)
{
string path = "/WebSite1/ajaxpro/Default3,";
path += typeof(Default3).Assembly.FullName.Split(',')[0];
path += ".ashx";
hUrl.Value = path;
}
[AjaxPro.AjaxMethod]
public string HelloWorld()
{
return "<div id=div1>aaaa</div>";
}
上边有个div1鼠标滑过事件 这样从后台过来的滑过事件就不执行 为什么怎么才能执行 在线等
------解决思路----------------------
不是很明白楼主 在使用了 $.ajax的前提下还要使用 ajaxpro 是为什么
直接调用 Default3.HelloWorld().value 不能满足你的要求?
若要非得使用此方式 访问
$.ajax(
{
type: "POST",
url: vUrl,
beforeSend: function (xhr) {
xhr.setRequestHeader("Content-Type", "text/plain;charset=utf-8");
xhr.setRequestHeader("X-" + AjaxPro.ID + "-Method", "HelloWorld");
if (!MS.Browser.isIE) {
xhr.setRequestHeader("Connection", "close"); // Mozilla Bug #246651
}
},
success: function (s) {
alert(eval(s + "*" + "/"));
}
});
});
以上 支持 非ie 系列 ,ie系列请求楼主有兴趣的话就看 ajaxpro 中core.ashx等文件
中ajaxpro是如何构造 的 xmlhttp请求