jQuery $.ajax request of dataType json will not retrieve data from PHP script

前端 未结 8 972
情话喂你
情话喂你 2020-11-30 03:31

I\'ve been looking all over for the solution but I cannot find anything that works. I am trying to get a bunch of data from the database and then via AJAX autocomplete input

8条回答
  •  無奈伤痛
    2020-11-30 03:57

    Try using jQuery.parseJSON when you get the data back.

    type: "POST",
    dataType: "json",
    url: url,
    data: { get_member: id },
    success: function(data) { 
        response = jQuery.parseJSON(data);
        $("input[ name = type ]:eq(" + response.type + " )")
            .attr("checked", "checked");
        $("input[ name = name ]").val( response.name);
        $("input[ name = fname ]").val( response.fname);
        $("input[ name = lname ]").val( response.lname);
        $("input[ name = email ]").val( response.email);
        $("input[ name = phone ]").val( response.phone);
        $("input[ name = website ]").val( response.website);
        $("#admin_member_img")
            .attr("src", "images/member_images/" + response.image);
    },
    error: function(error) {
        alert(error);
    }
    

提交回复
热议问题