Using the following Action Route and Javascript I'm working on passing multiple integar's to a cart when I enter the qty into the feild and onclick I'm hit with the following server error
Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking
for (or one of its dependencies) could have been removed, had its name changed, or
is temporarily unavailable. Please review the following URL and make sure that it
is spelled correctly.
Requested URL: /cart/addproduct/2/quantity/undefined
I'm aware that there is an error in the javascript Undefined should be a number I think.
I have highligthed in bold the Id selector and input button I can see that the Quantity is mapping correctly the Intger of the product but not the val/amount of inserted into the cart. How do I do the above you mentioned I don't know.
wertyuio1
Member
67 Points
116 Posts
Requested URL: /cart/addproduct/2/quantity/undefined
Aug 10, 2012 10:51 PM|LINK
<input type="button" value="@T("ShoppingCart.AddToCart")" class="productlistaddtocartbutton" onclick="setLocation('@(@Url.RouteUrl("AddProductToCart", new { productId = Model.Id }))/quantity/' + $('quantity_@(Model.Id)())"/>Using the following Action Route and Javascript I'm working on passing multiple integar's to a cart when I enter the qty into the feild and onclick I'm hit with the following server error
Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /cart/addproduct/2/quantity/undefined
I'm aware that there is an error in the javascript Undefined should be a number I think.
My question is
1. What do I need to change in the Javascript.
All help well app
Kind regards
R
ignatandrei
All-Star
134832 Points
21599 Posts
Moderator
MVP
Re: Requested URL: /cart/addproduct/2/quantity/undefined
Aug 11, 2012 03:36 PM|LINK
(@Url.RouteUrl("AddProductToCart", new { productId = Model.Id }))/quantity/' + $('@("quantity_" + Model.Id)')wertyuio1
Member
67 Points
116 Posts
Re: Requested URL: /cart/addproduct/2/quantity/undefined
Aug 11, 2012 04:19 PM|LINK
Hi
Still returning undefined. How do I define this value... If you don't mind me asking???
Thanks
Richard
BU XI - MSFT
All-Star
22367 Points
2704 Posts
Microsoft
Re: Requested URL: /cart/addproduct/2/quantity/undefined
Aug 14, 2012 05:44 AM|LINK
Hello
If the request is sent via javascript, you'll look into the code see if there is a AJAX call.
The undefined text may suggest that the URL is concatenated by a javascript variable.
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
wertyuio1
Member
67 Points
116 Posts
Re: Requested URL: /cart/addproduct/2/quantity/undefined
Aug 14, 2012 08:03 AM|LINK
Hello
This is the code in my partial view. How would I go about concatenating an variable.
@model Nop.Web.Models.Catalog.ProductModel @using Nop.Web.Models.Catalog <tr> <td class="picture"> <a href="javascript:OpenWindow('@Url.RouteUrl("Product", new { productId = Model.Id, SeName = Model.SeName, formId = "Product-form" }))', 450, 600, true);" title="@Model.DefaultPictureModel.Title"> <img alt="@Model.DefaultPictureModel.AlternateText" src="@Model.DefaultPictureModel.ImageUrl" title="@Model.DefaultPictureModel.Title" /> </a> </td> <td class="stockcode"> @Model.CCCStockCode </td> <td class="name"> @Model.Name </td> <td class="pack"> @Model.CCCPack </td> <td class="price"> @Html.Partial("_ProductPrice", Model.ProductPrice) </td> <td class="rrp"> £@Model.CCCRetailPrice </td> <td> <input type="text" id="quantity_(@Model.Id)" value="1" size="1" /> <input type="button" value="@T("ShoppingCart.AddToCart")" class="productlistaddtocartbutton" onclick="setLocation('@(@Url.RouteUrl("AddProductToCart", new { productId = Model.Id }))/quantity/' + $('#quantity_@(Model.Id)').val())"/> </td> </tr>In source code when launching in IE I have the following.
<tr> <td class="picture"> <a href="javascript:OpenWindow('/p/66/baby-active-350g-baby-talcum-powder?formId=Product-form)', 450, 600, true);" title="Show details for BABY-ACTIVE 350G BABY TALCUM POWDER"> <img alt="Picture of BABY-ACTIVE 350G BABY TALCUM POWDER" src="http://localhost:57436/content/images/thumbs/noDefaultImage_80.gif" title="Show details for BABY-ACTIVE 350G BABY TALCUM POWDER" /> </a> </td> <td class="stockcode"> 8MBA05 </td> <td class="name"> BABY-ACTIVE 350G BABY TALCUM POWDER </td> <td class="pack"> 6 </td> <td class="price"> <span class="productPrice">£3.30</span> </td> <td class="rrp"> £0.99 </td> <td> <input type="text" id="quantity_(66)" value="1" size="1" /> <input type="button" value="Add to cart" class="productlistaddtocartbutton" onclick="setLocation('/cart/addproduct/66/quantity/' + $('#quantity_66').val())" /> </td> </tr><script type="text/Javascript">$(document).ready(function (){$("AddProductToCart").click(function AddProductToCart(){return{$('#quantity_Model.Id').val())});</script>I have highligthed in bold the Id selector and input button I can see that the Quantity is mapping correctly the Intger of the product but not the val/amount of inserted into the cart. How do I do the above you mentioned I don't know.
Kind regards
Richard.
dvsspr
Member
73 Points
43 Posts
Re: Requested URL: /cart/addproduct/2/quantity/undefined
Aug 14, 2012 12:54 PM|LINK
Hi Richard,
I notice that the id attribute doesn't match with your selector.
Please adjust your template so that it will produce this line instead of the previous one.