tags:

views:

371

answers:

2

I am trying to get Yahoo stock quote in the following way. but it does not work, can anyone tell where is wrong. Thanks!

<html>
<head>
   <script type="text/javascript" src="jquery-1.3.2.js"></script>
   <script type="text/javascript" language="JavaScript">

    $(document).ready(function(){
            $("#btn").click(function(event){
              alert(document.forms[0].ticker.value);
              $("#stockPrice").load("http://finance.yahoo.com/q?s=ibm #yfs_l10_ibm").text(); 
     });
 });

    </script>
<body>


<form name="myForm">
Ticker: <input type="text" name="ticker" id="ticker"/>
<input type="button" id="btn" value="get quote"/>
</form>

</body>
</head>
</html>
+5  A: 

assuming you meant it doesnt work. thats probably because you are trying to do cross domain ajax request which is prohibited. see http://www.ajax-cross-domain.com/

Funky Dude
In addition, if you want it to work, create a php/asp page that uses "Curl" to fetch the information you want and retrieve it via $.ajax or other method in jQuery.
yoda
Is there any good article to explain cross domain request?
Southsouth
A: 

I changed from $("#stockPrice").load("http://finance.yahoo.com/q?s=ibm #yfs_l10_ibm).text() to
$("#stockPrice").load("ibm.dat"),text() and copied the data to ibm.dat But I still have the following problem.

Message: Unexpected call to method or property access. Line: 255 Char: 5 Code: 0 URI: file:///C:/Javascripts/jQuery/jquery-1.3.2.js

any idea?

Southsouth
really dont need text() at the end there. load() loads data into stockprice div
Funky Dude