拆分ajax返回值

I think what I'm trying to do is pretty simple, but I'm stuck. I'm trying to split the returned value of my ajax function. I don't think I'm correctly specifying the return value to split. Code is below.

 <script>
 function showCars(){
   var name = document.getElementById(“carID”).value;

   $.ajax({
        url : "<%=context%>/ListCarServlet?name=" + name,
        type : "POST",
        async : false,
        success : function(data) {
                 String[2] a = data.split("|");   //<———don’t think i’m splitting return value correctly
                document.getElementById(“value1”).value = a[0];
                document.getElementById(“value2”).value = a[1];         
        }
   });
 }
 </script>
查看全部
weixin_33698823
weixin_33698823
2017/05/01 03:56
  • jsp
  • ajax
  • javascript
  • 点赞
  • 收藏
  • 回答
    私信

2个回复