PDA

View Full Version : Get Prices Using Webservice



Bahaa-HS
03-05-2014, 04:31 PM
Dear Team,


I need to fetch symbols prices using WCF but i faced some troubles, please advise...







<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>GetNewTick</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<script >
var urlStr = "https://platform.gld1881.com/gld/WebService.svc";
function startGetNewTick() {
$.getJSON(urlStr + "/GetNewTick?callback=?", onSuccessResultAction);
}
function onSuccessResultAction(dataResult) {


result = eval('(' + dataResult + ')');


if (result == -201) {
var errDetail = "http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1964"
$("#resultAction").html("Error Code : " + dataResult + "<br/>" + " for more details see the follwing link: " + errDetail.link(errDetail));
}


if (result.Symbols.length > 0) {
var myTable = '<table border="1px"><thead>' +
'<tr><th>Symbol </th><th> Bid</th>' +
'<th >Ask</th><th>High</th><th>Low</th></tr></thead><tbody>';
for (var i = 0; i <= result.Symbols.length - 1; i++) {
myTable += "<tr>"
myTable += "<td>" + result.Symbols[i].I + "</td>"
myTable += "<td>" + result.Symbols[i].A + "</td>"
myTable += "<td>" + result.Symbols[i].B + "</td>"
myTable += "<td>" + result.Symbols[i].H + "</td>"
myTable += "<td>" + result.Symbols[i].L + "</td>"
myTable += "</tr>"
}
myTable += '</tbody></table>';
$("#resultAction").html(myTable);
}
else { $("#resultAction").html("No Price Update"); }
setTimeout('startGetNewTick()', '2000');
}
$(document).ready(function () {
jQuery.support.cors = true;
startGetNewTick();
});
</script>
<body>
<div id="resultData"> </div>
<div id="resultAction"> </div>
<div style="display:none" id="progress">Loading ... </div>
</body>
</html>

Hassan-HS
03-05-2014, 05:39 PM
Hello,


Please use this method...




$.getJSON(urlStr + "/GetMwNewTick?callback=?", onSuccessResultAction);


instead of




$.getJSON(urlStr + "/GetNewTick?callback=?", onSuccessResultAction);



Full Code...




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>GetNewTick</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<script >
var urlStr = "https://platform.gld1881.com/gld/WebService.svc";
function startGetNewTick() {
$.getJSON(urlStr + "/GetMwNewTick?callback=?", onSuccessResultAction);
}
function onSuccessResultAction(dataResult) {


result = eval('(' + dataResult + ')');


if (result == -201) {
var errDetail = "http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1964"
$("#resultAction").html("Error Code : " + dataResult + "<br/>" + " for more details see the follwing link: " + errDetail.link(errDetail));
}


if (result.Symbols.length > 0) {
var myTable = '<table border="1px"><thead>' +
'<tr><th>Symbol </th><th> Bid</th>' +
'<th >Ask</th><th>High</th><th>Low</th></tr></thead><tbody>';
for (var i = 0; i <= result.Symbols.length - 1; i++) {
myTable += "<tr>"
myTable += "<td>" + result.Symbols[i].I + "</td>"
myTable += "<td>" + result.Symbols[i].A + "</td>"
myTable += "<td>" + result.Symbols[i].B + "</td>"
myTable += "<td>" + result.Symbols[i].H + "</td>"
myTable += "<td>" + result.Symbols[i].L + "</td>"
myTable += "</tr>"
}
myTable += '</tbody></table>';
$("#resultAction").html(myTable);
}
else { $("#resultAction").html("No Price Update"); }
setTimeout('startGetNewTick()', '2000');
}
$(document).ready(function () {
jQuery.support.cors = true;
startGetNewTick();
});
</script>
<body>
<div id="resultData"> </div>
<div id="resultAction"> </div>
<div style="display:none" id="progress">Loading ... </div>
</body>
</html>

gld1881
03-17-2014, 02:52 PM
this code is not working again. please suggest the solution.

Hassan-HS
03-17-2014, 03:26 PM
Hello,


I will check it, please standby...

Hassan-HS
03-17-2014, 03:29 PM
Hello,



Its working now...please check it and confirm it ok or not