我们可以在母版页中使用jquery ajax调用吗? [英] Can we use jquery ajax call in master page?
问题描述
我想要Master页面中的Ajax请求。但它并没有打电话给ajax Call.Can你能告诉我。
我尝试了什么:
< script type =text / javascriptsrc =http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js> ;< / script>
< script type =text / javascriptsrc =http://cdn.jsdelivr.net/json2/0.1/json2.js>< /脚本>
< script type =text / javascript>
$(function(){
$([id * = btnSignup])。bind(click,function(){
var user = {};
user.Firstname = $([id * = txtFName ])。val();
user.Lastname = $([id * = txtLname])。val();
user.Email = $( [id * = txtEmail])。val();
user.Mobile = $([id * = txtMobile])。val();
user.Password = $([id * = txtPassword])。val();
$ .ajax({
type:POST,>
url:EventFr ont.Master / SaveUser,
数据:'{user:'+ JSON.stringify(user)+'}',
contentType:application / json; charset = utf-8,
dataType:json,
成功:功能(响应){
alert(用户已经过成功添加。);
window.location.reload();
}
});
返回false;
});
});
< / script>
I Want Ajax Request In Master page. But its doesn't called the ajax Call.Can u please advice me.
What I have tried:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="http://cdn.jsdelivr.net/json2/0.1/json2.js"></script>
<script type="text/javascript">
$(function () {
$("[id*=btnSignup]").bind("click", function () {
var user = {};
user.Firstname = $("[id*=txtFName]").val();
user.Lastname = $("[id*=txtLname]").val();
user.Email = $("[id*=txtEmail]").val();
user.Mobile = $("[id*=txtMobile]").val();
user.Password = $("[id*=txtPassword]").val();
$.ajax({
type: "POST",
url: "EventFront.Master/SaveUser",
data: '{user: ' + JSON.stringify(user) + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert("User has been added successfully.");
window.location.reload();
}
});
return false;
});
});
</script>
推荐答案
(function(){
(function () {
([id * = btnSignup])。bind(click,function(){
var user = {};
user.Firstname =
("[id*=btnSignup]").bind("click", function () {
var user = {};
user.Firstname =
([id * = txtFName])。val();
user.Lastname =
("[id*=txtFName]").val();
user.Lastname =
这篇关于我们可以在母版页中使用jquery ajax调用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!