如何使用jQueryAjax后响应参数

How to use jQuery Ajax post response params

本文关键字:响应 参数 jQueryAjax 何使用      更新时间:2023-09-26

我想使用在Ajax响应中收到的参数,但我收到的是一个简单的字符串。

Ajax:

$.ajax({
    type: 'POST',
    url: url,
    data: str
}).done(function(res){
    // res is a simple string
    // => ResponseCode=0&Description=OK
});

假设我需要使用Description参数的值(OK)。

$.ajax({
    type: 'POST',
    url: url,
    dataType : "json", // define type 
    data: str,
    error : function( er ){ console.log( e );},
    success: function( response ){
    console.log( response );
});