JQuery Ajax callback function value out of the alert [object Object] solution

Recommended for you: Get network issues from WhatsUp Gold. Not end users.
$("#activity_project").change(function(){
        var pro=$("#activity_project").val();
     $.ajax({
         type: "POST",
         url: "${pageContext.request.contextPath}/getMyPlan",
         data: { //Sent to the database
             idKey:pro
             },
         dataType: 'json',
         success: function(data) {
                 alert(data);
              $.each(data, function(index,value){
                  alert(data[index].id);

$("#activity_project").append('<option value="data[index].id">data[index].specification</option>');              });
             }
  })
     })

  

It is recommended to use console.log (data); the output results


The results of Google browser

Another method is to modify the code

 Results alert is out of object XML document, this makes me very confusing, the output is the string, why the transmission format is XML?

response.setContentType("text/html;charset=UTF-8"); Alert is the string you want.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Payne at November 16, 2013 - 5:16 PM