JQuery $.post not working properly
Posted
by drupop
on Stack Overflow
See other posts from Stack Overflow
or by drupop
Published on 2010-04-13T11:19:34Z
Indexed on
2010/04/13
11:23 UTC
Read the original article
Hit count: 346
Can't seem to find a fix for this issue
I have the following code on the onclick event of an a html tag:
AddVacationToCart(
{
ServiceSupplier:'Kiki',
ProductId:'0;11968;0;0;187;1',
Name:'Excelsior',
NumberOfStars:'*****',
TotalPrice:'1620.00',
PriceLevelName:'Standard',
Currency:'EUR', Status:'',
StartDate:'2010-06-17',
EndDate:'2010-06-24',
NumberOfNights:'7',
Rooms:[
{
NumberOfAdults:'2',
NumberOfChildren:'0',
ChildrenAges:[]
}
]
},'0;11968;0;0;187;1');return false;
I also have this code:
function AddVacationToCart(vacation, id) {
$.post("/ShoppingCart.mvc/AddVacation",
vacation,
function(data) {
var div = $("div[id*=cartv" + id + "]");
var removeFromCartHtml = "Adaugat";
$(div).html(removeFromCartHtml);
}, "json");
}
This is the code in my ShoppingCartController AddVacation Action:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult AddVacation(Vacation test)
{
...
}
The post works as in the (Vacation) test object gets filled with the corresponding properties like ServiceSupplier, ProductId, Name etc. Except the properties of my Rooms field do not get their corresponding values. Any ideeas?
© Stack Overflow or respective owner