开发者

Getting ajax output from a site?

Hi people i want the functionality of the following website page in my site http://www.unlockcodesource.com/buy_unlockcode_now.php

when user select the make of phone(number 3) in the page the ajax call happens in

http://www.unlockcodesource.com/ajax.js

and select network provider(select box) (number 5)changes according to it. I have try to write some code to achieve that functionality. First i created test.html file and there is following code in it.

<html lang="en">
<head>
<title><!-- Insert your title here --></title>
<script language="javascript" src="ajax2.js"></script>
</head>
<body>
<!-- Insert your content here -->
<div id="buynow_container">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="paypalform">
<select name="os1" onchange="GetNetworks(this.value,'select_make');">
                        <option selected value="0">Please select one</option>
                    <option             value="Acer">Acer</option>
                              <option value="Alcat开发者_JAVA技巧el">Alcatel</option>
                                                            <option value="Blackberry">Blackberry</option>
                                                            <option value="Dell">Dell</option>
                                                            <option value="G2X">G2X</option>
                                                            <option value="Garmin">Garmin</option>
                                                            <option value="Google">Google</option>
                                                            <option value="HP">HP</option>
                                                            <option value="HTC">HTC</option>
                                                            <option value="Huawei">Huawei</option>
                                                            <option value="INQ">INQ</option>
                                                            <option value="Iphone">Iphone</option>
                                                            <option value="LG">LG</option>
                                                            <option value="Motorola">Motorola</option>
                                                            <option value="Nokia">Nokia</option>
                                                            <option value="Optimus 2X">Optimus 2X</option>
                                                            <option value="Palm">Palm</option>
                                                            <option value="Pantech">Pantech</option>
                                                            <option value="Samsung">Samsung</option>
                                                            <option value="Sharp">Sharp</option>
                                                            <option value="Sidekick">Sidekick</option>
                                                            <option value="Siemens">Siemens</option>
                                                            <option value="Sony Ericsson">Sony Ericsson</option>
                                                            <option value="Zte">Zte</option>
                                                    </select>
                   <div id="select_make">
              <select name="network" >
                    <option selected value="0">Please select make first!</option>
                </select>
                </div>

</form>
</div>
</body>
</html>

and in ajax2 .js

    function GetNetworks(value,divID) {
var xmlhttp;
xmlhttp = startAjax();
xmlhttp.onreadystatechange=function() { 
    if (xmlhttp.readyState==4) {
            document.getElementById(divID).innerHTML = xmlhttp.responseText;

            alert(xmlhttp.responseText);

    }   

}
xmlhttp.open("GET","http://www.unlockcodesource.com/getnetwork_list.php?ID="+divID+"&make="+value,true);
xmlhttp.send(null);         
    }

but xmlhttp.responseText is returning null. Thanks plz help. If you know any other solution like parsing or curl then please give some direction . Thanks


Here for the little story behind the restriction of cross domain call Wikipedia

One of the solution you have is to use your server (the same domain) as a proxy, by proxy I mean a webpage that would fetch the content on the other domain and send it back to the client.

now ethically I am not sure if it's a good idea.


EDIT
Just noticed that you've posted JS that shows you are indeed trying to use data from the website you've mentioned so my answer is kinda irrelevant now. But I'm going to leave it here in case you find that you need this information later.


As @mario mentions in the comment, if you're trying to use the data from that website, you can't.

However, if you're looking to implement the dependent/chained select boxes, you might want to check out these jQuery plugins:

  • http://plugins.jquery.com/project/related-selects
  • http://www.appelsiini.net/2010/jquery-chained-selects
  • https://code.google.com/p/jqueryselectcombo/

Here are a couple of tutorials without plugins:

  • http://remysharp.com/2007/01/20/auto-populating-select-boxes-using-jquery-ajax/
  • http://www.9lessons.info/2010/08/dynamic-dependent-select-box-using.html
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜