2012-02-28 97 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