ASHX Ajax with custom JavaScript functions

Source: Internet
Author: User

1.getUserPower is a custom JavaScript function

Get Permissions

(1). The relative address of the. ASHX handler (must be a relative address)
(2). AU permission name
(3). ClassName Class Name
(4). Funsuccess A successful event, function.
*/
$.fn.getuserpower = function (operate, mdlname, funsuccess) {
$ (this). Click (Function (event) {
if (cookie = = "Admin") {
if (Mdlname = = "Sectioninfomag" | | mdlname = = "Toolssectionmag" | | mdlname = "TOOLSINFOMAG" | | mdlname = "PARAMINFOMAG") {
Alert ("Admin user does not have this permission!") ");
return false;
}
else {
Funsuccess (); Things to do after success
return true;
}
}
Cancels the execution of other event handlers and cancels the event bubbling. If multiple event handlers are bound to the same event, calling this method in one of the event handlers will not continue to invoke other event handlers
Event.stopimmediatepropagation ();
$.get (ashx
, {key: "Byone", Operate:operate, Userid:cookie, mdlname:mdlname}
, function (data, textstatus) {
if (Textstatus = = "Success") {//Get success
if (data = = "true") {
Funsuccess (); Things to do after success
} else if (data = = "false") {
Alert ("No permission! ");
return false;
} else {
alert (data);
return false;
}
} else {
alert (textstatus);
return false;
}
})
});

};

Calls between 2.ashx and Ajax

$ ("#btn_del"). Getuserpower ("Del", "Paraminfomag", function ()
{
var tid = $ (": Checked"). Getbind ("Tid", ",");
if (tid = = "") {
Alert ("Please select the row to delete!");
Return
} else {

Determine if the current user has permission to delete the selected tightening parameter information
$.get (".. /ashx/paraminfomag.ashx? "+ New Date (), {key:" Delpower ", Ids:tid}, function (data, textstatus) {
if (Data! = "true")
{
alert (data);
Return
}
Else
{
if (!confirm ("Are you sure you want to delete? ")) {
Return
}

$.get (".. /ashx/paraminfomag.ashx? "+ New Date (), {key:" Del ", Ids:tid}, function (data, textstatus) {

if (Textstatus = = "Success") {
if (data = = "true") {
Alert ("Delete succeeded! ");
$ ("#img_sel"). Click ();
window.location = "paraminfo.aspx";
} else if (data = = "false") {
Alert ("Delete failed! ");
} else {
alert (data);
}
} else {
alert (textstatus);
}

}); Get
}
});

}
});

ASHX Ajax with custom JavaScript functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.