English 中文(简体)
页: 1 Qu
原标题:jQuery inserting a page into div breaks javascript

我的指数.php有一条叫.的ja子,加插头。 php 载于我的编号。 罚款。 问题就是说话。 php有几处 j(更多的 j),而 Chrome则执行手法罚款,即:

如果我把 j瓦片作为卷宗(set塞),则火包正在检查。 js_=1322020697832

如果我把java文直接列入张贴站。 php完全无视javascript(甚至在源代码中显示)

是否有任何人知道如何确定?

指数.php

<script type="text/javascript" src="fetchposts.js"></script>
<div id="content"></div>

fetchposts.js

$(document).ready(function() {
$.ajax({
    url:  getposts.php ,
    type:  POST ,
    success: function (fetched) {
        $( #content ).load( getposts.php );
    },
});
});

登出哨所.php(这使火力上升。 js_=1322020697832

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

或获得职位。 php(垃圾箱完全没有来源代码)

<script type="text/javascript">
$(document).ready(function() {
// set $checked values
$.ajax({
    url:  query.php ,
    type:  POST ,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    async: true,
    cache: false,
    success: function (msg) {
        ------ do some fun stuff that works --------
    },
});
});
</script>
         --------------- some php and html that DOES display -------------

我的问题再次暴露了我的 j言的内容,而是如何在“大陆”内找到 j。 Chrome的确在没有问题的情况下执行该守则。 出于某种原因,它是燃烧。 消防局没有发现错误,除了寻找错误档案或完全无视错误档案。

其余获得者.php(html和php代码) DOES显示在我的Nocontent和José和Grea。

最佳回答

I know that the scripts are working, but I think that they need some refactoring. From the code I see that you are

  1. Loading content from getposts.php into the #content
  2. Once loaded, you want to get some JSON
  3. When JSON is loaded, you want to some fun stuff with it

可通过:

  • Not making so many ajax calls
  • Using specialized, ajax methods specifically for each task
  • Putting them within a single file

fetchposts.js

$(document).ready(function() {
    var someFunStuff = function(msg) {
        // do some fun stuff that works 
    };

    var setChecked = function() {
        $.getJSON( query.php , someFunStuff);
    };

    $( #content ).load( getposts.php , setChecked);
});

如果我误解了你想要做的事情,或你需要作一些更多的说明,那么,让我知道,我将视需要作出回应。

Update

我看到你对使用单一javascript文档所作的评论。 你们需要从单独的数据库获得什么?

问题回答

暂无回答




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签