-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbidding.js
61 lines (55 loc) · 1.79 KB
/
bidding.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//Creating xHR object for Ajax request
var xHRObject = false;
//For browsers other than IE
if(window.XMLHttpRequest)
xHRObject = new XMLHttpRequest();
else if(window.ActiveXObject)
xHRObject = new ActiveXObject("Microsoft.XMLHTTP");////For browsers IE
//Function called on pageload to get the items which are in auction
function getItems()
{
xHRObject.open("GET", "fetchItems.php?id=" + Number(new Date), true);
xHRObject.onreadystatechange = function()
{
if (xHRObject.readyState == 4 && xHRObject.status == 200)
{
var htmlResponse = xHRObject.responseText;
document.getElementById("result").innerHTML = htmlResponse;
//alert(xmlDoc);
}
}
xHRObject.send(null);
}
//Function called on place bid button clicked, opens a new window and pass item number and Current bid as query strings
function fnPlaceBid(itemNumber,currentBid)
{
window.open('placeBid.php?itemNumber='+itemNumber+'¤tBid='+currentBid,'name','width=600,height=400');
return false;
}
//Function calls a php page to update the status of an item for Buy Now button
function fnBuyNow(itemNumber)
{
if(confirm('Are you sure to purchase the item now?'))
{
var xmlFile = "../../data/auction.xml";
if (xHRObject.overrideMimeType)
{
xHRObject.overrideMimeType("text/xml");
}
if(xHRObject)
{
var bodyofrequest = "itemNumber=" + encodeURIComponent(itemNumber);
xHRObject.open("POST", "updateItem.php", false); //Sync
xHRObject.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xHRObject.onreadystatechange = function()
{
if (xHRObject.readyState == 4 && xHRObject.status == 200)
{
var serverText = xHRObject.responseText;
alert(serverText);
}
}
xHRObject.send(bodyofrequest);
}
}
}