开发者

problem adding success to jquery post

开发者 https://www.devze.com 2023-03-11 18:24 出处:网络
I have this code here and want to attach a success function but dont know how. Can anyone please advise?

I have this code here and want to attach a success function but dont know how. Can anyone please advise?

$.post('SendEmail.aspx',
         {emai开发者_C百科lbody: emailBody})


See the examples, it's pretty straightforward.

http://api.jquery.com/jQuery.post/


$.post('SendEmail.aspx', {emailbody: emailBody}, function(result) {
    //success function here
})

EDIT

If you want to handle errors, you need to call the full $.ajax() function like this:

$.ajax({
    type: 'POST',
    url: 'SendEmail.aspx',
    data: {emailbody: emailBody},
    success: function(result){ //success function code},
    error: function(result){ //error function code},
    dataType: 'json'
});

Check out this link for all the ajax settings

0

精彩评论

暂无评论...
验证码 换一张
取 消