Here is a button:
<input type="button" value="add to cart" id="addToCart" />
and a bound event:
$("#addToCart").bind('click',function(){
$.ajax({
url: '/cartManager/add',
data:{
pictureId: currentImageId,
printSize: $("#size option:selected").val(),
paperType: $("#paperType option:selected").val(),
quantity: 1
},
success: function(){
$("#modal").html("<h1>ОК</h1><p>Closing in a sec</p>").delay(1000);
$("#modal").overlay().close();
}
});
return false;
});
And everything works find apart one thing that kind of bothers, I see two requests in Chrome dev console for this:
- add /cartManager:
Request URL:http://127.0.0.1:8000/cartManager/add?pictureId=4&printSize=2&paperType=1&quantity=1
Request Method:GET
Status Code:301 MOVED PERMANENTLY
- add /cartManager/add?:
Request URL:http://127.0.0.1:8000/cartManager/add/?pictureId=4&printSize=2&paperType=1&quantity=1
Request Method:GET
Status Code:201 CREATED
Request headers for both are pretty much the same, the only difference in request headers:
first is cartManager/add?pictureId= and so on and the second one is cartManager/add/?pictureId - the '/' after /add
Is there something wrong with my javascript?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…