jQuery ajax request with json response, how to?

后端 未结 5 971
一向
一向 2020-11-27 19:08

I am sending an ajax request with two post values, the first is "action" which defines what actions my php script has to parse, the other is "id" which i

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 19:32

    Try this code. You don't require the parse function because your data type is JSON so it is return JSON object.

    $.ajax({
        url : base_url+"Login/submit",
        type: "POST",
        dataType: "json",
        data : {
            'username': username,
            'password': password
        },
        success: function(data)
        {
            alert(data.status);
        }
    });
    

提交回复
热议问题