Web Analytics Made Easy -
StatCounter Make a post request - CodingForum


No announcement yet.

Make a post request

  • Filter
  • Time
  • Show
Clear All
new posts

  • Make a post request


    I am looking to send a post request to a server using javascript, I want to do this to minimize loading and click time as this request some times has to be sent multiple time.

    To send the request by normal browser emulation you click your choise and then hit the submit button, so there is no form. I have previously managed to do this for another site with some guidance.

    To illustrate what i am after i will post the "post" script here:

    for (var i=0;i<5;i++){ $.ajax({ url: "/market", method: "POST", data: {"carpurchase": "0"}});}
    I´m trying to obtain something very similar but has not managed to do it and wonder if someone can guide me towards an example or so for the syntax above.

    and if there is anyone willing to write the answere out I will be happy also.

       <div data-itemid="1" data-price="1" class="rbOpt" style="background: rgba(160,160,160,.1) url(//ng.crimecdn.com/svg/bank/9999999.svg) 6px center/28px 28px no-repeat;">
                        <span class="rbOptTitle">Stimulus Package </span><div class="rbOptPrice">1</div><br>
                        <span class="rbOptDesc">Get $100,000 cash instantly.</span>
                    <div data-itemid="2" data-price="10" class="rbOpt" style="background: rgba(160,160,160,.1) url(//ng.crimecdn.com/svg/heart/2999999.svg) 6px center/28px 28px no-repeat;">
                        <span class="rbOptTitle">Health Pack </span><div class="rbOptPrice">10</div><br>
                        <span class="rbOptDesc">Increase your health by 10%.</span>
                    <div data-itemid="3" data-price="150" class="rbOpt" style="background: rgba(160,160,160,.1) url(//ng.crimecdn.com/svg/bullets/2999999.svg) 6px center/28px 28px no-repeat;">
                        <span class="rbOptTitle">Bullet Cache </span><div class="rbOptPrice">150</div><br>
                        <span class="rbOptDesc">Get 10,000 bullets instantly.</span>
                                               /////////////// I want to send a post request with data-itemid="1"
                                             ////////////// the submit are looks like this:
       <div class="rbSub rbsu">
                <button class="btnPurchase red">Purchase</button><br><span class="priceText">This purchase will cost <span class="price">0</span> points.</span>
    Thank you very much

  • #2
    Your button should trigger a function. onclick() is the easiest way of doing that. The function contains your code. Why you need to send it over and over again is not right. Have you ever investigated why?
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.