I'm facing a bit of a challenge with what seems like a simple task. I am attempting to split the value returned by my ajax function, but I believe I may be specifying the return value incorrectly. The code in question is provided 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>