-1

I'm building a website ontop of e-commerce framework from Sweden. For this project the client wants me to manipulate the shopping cart. In the beginning I got it working so I know there's a way to do it(I switched method, that why I lost that and some more which you can read below). But!!

I render everything on the run, and i outputs buttons which if I press the buttons manually they work like a charm. So when finishing my work I thought I could just make a function that finds all buttons and click them manually, but NO. That submits the form which takes me to a page that's that only there to increment cart quantity.

Here's the div

<form method="post" action="/shoppingcart/increase_product_count/" 
class="product_form" name="product_built_div">
<input type="hidden" value="" name="product_id" id="kontroll">
<input type="submit" value="Kontroll"></form>

When looking at request they look like this if I click manually.

1743
/legacy-template-api/conceptual-id-lookup
GET
200
OK
text/plain
cache.js:2013
Script
369 B
4 B
348 ms
347 ms
347 ms1 ms
514f4eb04b96714970000004/
/carts
POST
200
OK
application/vnd.ebutik.cart+xml
cache.js:2013
Script
1.2 KB
878 B
216 ms
214 ms
214 ms2 ms
shoppingcart/
/shoppingcart/show_widget
GET
200
OK
text/html
cache.js:2013
Script 

Clicking like this this holds the correct info, I've checked aswell as I get sent to the product increment page.

 $(this).find('input[type=submit]').click();  

Request data for JQUERY .click()

increase_product_count/
/shoppingcart
POST
(pending)

Pending then turns into not found?

I did notice that i cant't find my built div in the page source I'm using chrome broswer. Is there another issue?

4

1 回答 1

2

To submit a form using jQuery, check out .submit()

To simulate clicks of other non-submit buttons, your .click() should work.

Alternatively to .click(), you can try .trigger("click").

Examples on using .submit()

于 2013-03-31T01:45:29.600 回答