onchange事件无法正常工作

时间:2013-08-07 18:50:26

标签: php javascript ajax onchange

我正在尝试从另一个页面获取数据,以便用户不必刷新数据工作正常但是当我使用任何类型的javascript脚本或css时它不适用于更改,而它工作正常直接进入页面

在另一个页面中定义的http

    /* ---------------------------- */
/* XMLHTTPRequest Enable */
/* ---------------------------- */
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}

var http = createObject();

这是要显示的页面

<script>

  var nocache = 0;
  function product_js() {

  document.getElementById('insert_response').innerHTML = "Please wait"

  var id = encodeURI(document.getElementById('id').value);

  nocache = Math.random();

  http.open('get', 'runtime/product.php?id='+id+'&nocache='+nocache);
  http.onreadystatechange = insertReply;
  http.send(null);
  }
  function insertReply() {
  if(http.readyState == 4){
  var response = http.responseText;

  document.getElementById('insert_response').innerHTML = ''+response+'';
  }
  }
  </script>
<select id="id" onchange="javascript:product_js()" class="text">
        <option value="select">Select</option>
               <option value="1">One</option>
               <option value="3">One</option>

           </select>
            <div id="insert_response" align="center"></div>

现在是product.php页面

    <?php
echo $_GET['id'];
?>
<head>
<script type="text/javascript" src="../js/jquery.js"></script>

<script type="text/javascript" src="../js/thumbnailviewer2.js">


</script>
</head>
<a href="../images/1.jpg" rel="enlargeimage" rev="targetdiv:loadarea" title="The Universe is just waiting to be explored">Saturn #1</a><br />
<a href="../images/1.jpg" rel="enlargeimage" rev="targetdiv:loadarea,link:http://afterdoor.com">The Moon #1</a><br />


<div id="loadarea" style="width: 600px"></div>

当我直接访问文件时它给出正确的输出但是当我通过ajax访问文件时图像&amp; javascript部分无法正常工作,而php部分工作文件甚至与数据库,但没有任何种类的JavaScript或CSS请帮助它

0 个答案:

没有答案