2012-02-28 91 views
0

如何将警报更改为标签?标签上的Ajax Jquery成功消息

   $.ajax({ 
       type: "POST", 
       url: pageUrl + '/ProcessADRequest', 
       data: '{SSNID: "' + $("[id$='_empLast4Txt']").val() + '", DOB: "' + $("[id$='_empDobTxt']").val() + '"}', 
       contentType: "application/json; charset=utf-8", 
       dataType: "json", 
       success: function (response) { alert(response.d); }, 
       failure: function (response) { alert(response.d); } 

      }); 
+0

你需要更具体。而不是在警报框中呈现响应,而是希望将标签添加到页面中? – TheDelChop 2012-02-28 18:55:21

+0

是的,我想要在一个标签中呈现结果。 – Ram 2012-02-28 20:03:42

回答

0

所以,如果你只是想呈现在标签和假设你要它追加到文档的主体,那么在这里你去

$.ajax({ 
     type: "POST", 
     url: pageUrl + '/ProcessADRequest', 
     data: '{SSNID: "' + $("[id$='_empLast4Txt']").val() + '", DOB: "' + $("[id$='_empDobTxt']").val() + '"}', 
     contentType: "application/json; charset=utf-8", 
     dataType: "json", 
     success: function (response) { $('body').append("<label>" +response.d + "</label>"); }, 
     failure: function (response) { alert(response.d); } 

     }); 
+0

我正在使用来验证我的表单。当我点击提交时,即使存在任何验证错误,它也会呈现对标签的响应。我希望它只在表单提交后才提供响应。我怎样才能做到这一点? – Ram 2012-02-28 23:09:30