简体   繁体   English

Ajax成功使用html dataType

[英]Ajax success with html dataType

I'm doing an Ajax call with html dataType to a PHP file. 我正在用html dataType对PHP文件进行Ajax调用。 The php file answers with html code which includes a <script> and a <li> php文件用包含<script><li> html代码回答。

<script type="text/javascript">
    ..some code which manages a javascript array
</script>

<li>info about something</li>

In the javascript client I need only the <li> but when I try to use the data and put it inside a <ul> with id='list' , I have an error 在javascript客户端中,我只需要<li>但是当我尝试使用数据并将其放在id='list'<ul>时,出现错误

..ajax..
success: function(data){
  $('#list').html(data);
}
..

Uncaught SyntaxError: Unexpected identifier 未捕获的SyntaxError:意外的标识符

$.ajax({ method: 'GET', 

    url: 'phpelenco_canzoni.php', 
    dataType: 'html', 

    success: function(data){ 

        $('#list').html(data); 

} // <-- });

change 更改

$.ajax({ method: 'GET', 

    url: 'phpelenco_canzoni.php', 
    dataType: 'html', 

    success: function(data){ 

        $('#list').html(data); 

}});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM