2012-01-20 49 views
0

所以我試圖使用jQuery的.post函數來提交表單並在同一頁面上返回結果。我試過使用jquery's documentation中的示例。表單已成功提交,但沒有任何內容返回到表單頁面。Jquery .post()遠程提交

我有我的JS設置,如:

上test3.php形式腳本的相關部分的樣子:

<div id="form_results"> 
<script type='text/javascript'><!--//<![CDATA[ 

    var m3_u = (location.protocol=='https:'?'https://mydomain.com/openx/www/delivery/rtl.php':'http://mydomain.com/openx/www/delivery/rtl.php'); 

    var m3_r = Math.floor(Math.random()*99999999999); 

    if (!document.MAX_used) document.MAX_used = ','; 

    document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u); 

    document.write ("?zoneid=4"); 

    document.write ('&amp;cb=' + m3_r); 



//you Should pass your Keyword 

    document.write ('&amp;keyword=<?php echo urlencode($_POST["keyword"]);?>'); 

//you Should pass your Zipcode 

document.write ('&amp;zipcode=<?php echo urlencode($_POST["zip"]);?>'); 



    if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used); 

    document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : '')); 

    document.write ("&amp;loc=" + escape(window.location)); 

    if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer)); 

    if (document.context) document.write ("&context=" + escape(document.context)); 

    if (document.mmm_fo) document.write ("&amp;mmm_fo=1"); 

    document.write ("'><\/scr"+"ipt>"); 

//]]>--></script><noscript><a href='http://mydomain.com/openx/www/delivery/ck.php?n=a9d134b1&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://mydomain.com/openx/www/delivery/avw.php?zoneid=4&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=a9d134b1' border='0' alt='' /></a></noscript> 
    </div> 

我在做什麼錯在這裏?爲什麼它不會將結果返回到#result div?我看過這些標題,所以我知道數據已成功通過。

+0

在Chrome中,執行該帖子並查看網絡部分。看看回應是什麼。 – teynon

+0

同時檢出$ .post()方法中從回調中返回的數據。 –

回答

0

如果有人有興趣,我發現這個問題沒有可能的解決方案,短缺實施像JSON-P黑客。它不起作用,因爲它違反了同域政策。感謝任何看着這個並試圖弄清楚發生了什麼的人。