0

I have some code where the user enters some values on one page, and this gets saved to localStorage. On the other page all of these values are grabbed from localStorage, and put inside a table like so:

function displayCart(){
    var cartArray = listCart();
    var outputProduct2 = "";
    for (var i in cartArray){
        outputProduct2 += 

        "<tr>"
        +"<td data-name='name'>"
        + "VM Naam: "
        + cartArray[i].vmnaam + ""
        +"</br>"
        +cartArray[i].name + ""
        +"</br>"
        +"ram:"
        +cartArray[i].ram
        +"</br>"
        +"diskSpace:"
        +cartArray[i].diskSpace
        +"</br>"
        +"cpu:"
        +cartArray[i].cpu
        +"</td>"
        +"<td data-price='Price'>"
        +cartArray[i].price
        +"</td>"
        +"<td data-quantity='Quantity'>"
        +cartArray[i].quantity
        +" <button class='btn btn-primary' data-name='"
        +cartArray[i].name+"'>+</button>"
        +"<button class='btn btn-success' data-name='"
        +cartArray[i].name+"'>-</button>"
        +"</td>"
        +"<td data-name='subtotal' class='text-center'>"
        +cartArray[i].total
        +"</td>"
        +"<td class='actions' data-th=''>"
        + "  <button class = 'btn btn-danger' data-name = '"+cartArray[i].name+"'> X </button> " 
        +"</td>"
        +"</tr>"

    }


$("#shoppingcart2").html(outputProduct2);

the outputproduct2 gets printed to the following in the html code:

<tbody id = "shoppingcart2">

                    </tbody>

The question I have is how do I send these values to a java servlet. I have searched a bit and found out I have to use ajax for this, but I don't know how to start.

ekbayrak2
  • 41
  • 7

0 Answers0