I've done plenty of research and keep going round in circles. I have created an auction application which requires a "live bidding" process:
So I need to be able to perform GET statement to find the current highest bid(this will require some validation) I need to then perform a POST statement(again performing validation beforehand)
Difficulties:
I cannot find a solution that regularly updates the current bid. i.e. every 3-5 seconds check the bid is correct or just update it
There is a lot of conflicting information and as a newbie to PHP and Laravel I'm really stuck. And I do appreciate the amount of other similar questions out there but none adequately explain what is required or go into the level of detail required. so much so I'm starting to think jQuery/AJAX is not the correct action to complete this task.
Main.js (loaded in header of all php files )
var delay = 5000;
var getCurrentHighestBid = function() {
// perform validation here, if necessary
var url = '/items'; // insert your URL here
$.get(url, null, handleGetCurrentHighestBidResponse);
};
var handleGetCurrentHighestBidResponse = function(response) {
// check for nulls in response here, handle exceptions, etc
// then insert your bid data into the DOM, which may look
// something like:
$('.winner').html(response.Html);
setTimeout(getCurrentHighestBid , delay);
};
itemController.php (snippet)
public function show($id)
{
$item = Item::find($id);
//find higest bid fo item_auction id
$winningBid = Item::find($id)->bids()->max('bid_amount');
//var_dump($item);
return View::make('items.show', compact('item', 'winningBid'));
}
show.blade.php (view) (snippet)
<h4 id="winner">{{$winningBid }}</h4>