English 中文(简体)
宇宙航空研究开发机构用新的对应产出更新了PHP网页。
原标题:AJAX live update a PHP page with a new echo output
  • 时间:2011-06-21 18:49:45
  •  标签:
  • php
  • ajax
最佳回答

你们不需要日本宇宙航空研究开发机构的请求,但:

Your HTML:

<a href="/autoquote.php?discount=safedriver" discount="safedriver" class="discount-class">Safe Driver</a>
<a href="/autoquote.php?discount=unsafedriver" discount="unsafedriver" class="discount-class">Unsafe Driver</a>
<span class="result"></span>

阁下:

$(function(){
    $( a.discount-class ).click(function(){
        $.get( /autoquoteAjax.php?discount=  + $(this).attr( discount ), function(data) {
            $( .result ).html(data);
        });
    });
});

页: 1 Ajax.php:

switch(trim($_GET[ discount ])){
    case  safedriver :
        echo "Ask about a safe driver discount, which could save you up to 25% for drivers with no violations or at-fault accidents!";
    break;
    case  unsafedriver :
        echo "This will be expensive!";
    break;
}

请注意,<代码>discount=“safedriver”在XHTML中赢得了t

问题回答

我建议你看一下jQuery ,更具体地说,是.load(-method)。

http://www.google.com/search?q=jquery%20load%20example” rel=“nofollow”>net。

为了达到150%的诚实,我不认为,为了职业目的,你应当与日本宇宙航空研究开发机构和菲律宾航天中心一起玩 playing,除非你知道你做了些什么,只是因为你可以做很多事情,并且可以做些什么。

除此之外,我还认为,如果你再次要求这样做,那社区一般是好的,是因为你有了一个即将到来的最后期限,而不是因为你太 la了来学习这些语言。 正因为如此,我会给你这个法典:

* 表明 php应当使用一个称为/autoquoter.php的恰当网页。

JS:

function getXMLText(dname){
    if (window.XMLHttpRequest){
      xhttp=new XMLHttpRequest();
    }
    else{
      xhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xhttp.open("GET",dname,false);
    xhttp.send();
    return xhttp.responseText;
}
function safery(boolvar){
    if(boolvar){
        document.getElementById("changling").innerHTML = getXMLText("/autoquoter.php?discount=safedriver");
    }
    else{
        document.getElementById("changling").innerHTML = getXMLText("/autoquoter.php?discount=unsafedriver");   
    }
}

传真:

<a href="javascript:safery(true)">I am a safe driver</a><br />
<a href="javascript:safery(false)">I am NOT a safe driver</a><br />
<div id="changling"> </div>

然后将这一条放在<条码>autoquoter.php上。 页: 1

<?php switch(trim($_GET[ discount ])){
    case  safedriver :
        die("Ask about a safe driver discount, which could save you up to 25% for drivers with no violations or at-fault accidents!");
    break;
    case  unsafedriver :
        die("This will be expensive!");
    break; } ?>

而将整件材料视为一个联合材料,请上here(当然不使用php)。

现在,你们有时间去做,这样你就能够停止阅读。 我在此解释如下:

  1. Page is loaded
  2. When user clicks on a link the javascript queries that page (autoquoter.php) and funnels its output into the empty div called changeling
  3. autoquoter.php uses a standard switch statement to output the correct warning based on its GET variable




相关问题
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 ...