2011-07-28 144 views
0

如果我在</head>之前有以下代碼,php表單會發送但是 css會崩潰,並且不會顯示下拉菜單。PHP形式與......有衝突。

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> 

如果我沒有代碼,提交按鈕會刷新頁面,如果空白,並且從不發送任何內容,但下拉菜單不起作用。如果填寫了任何字段,提交按鈕將返回404.

如何保持兩者?

其他細節:

  • WordPress的CMS
  • jQuery的腳本插入在一個領域在WP定製的JS。
+1

你可以發佈一些其他包括? CSS如何「崩潰」?你有多個jQuery包含? – barfoon

+0

什麼形式? 「css崩潰」是什麼意思?我們需要看到相關的代碼(在問題中,而不是外部鏈接) –

+0

爲什麼你包括在線jQuery庫...而是下載jQuery庫並使用它.. – diEcho

回答

5

我知道JS是默認設置,但請嘗試將type="text/javascript"置於<script>標記中。此外,firefox的firebug有一個NET標籤,很可能會告訴你發生了什麼事情。如果你不能自己弄清楚,我會建議你發佈一個加載內容的屏幕截圖。

+0

它沒有工作。我會嘗試使用螢火蟲。 – Renan

0

WordPress可以通過手動嵌入式js和樣式嵌入來獲得挑剔。注入它們的正確方法是add_actionsinitprint_scriptsprint_sytles。以下,或者類似的東西添加到您的Functions.php

// register scripts 
if (! function_exists(register_scripts){ 
function register_scripts() { 
    wp_deregister_script('jquery'); 
    wp_register_script('jquery','http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js'); 
    } 
} 
add_action('init', 'register_scripts'); 

//print the now registered scripts 
if (! function_exists(print_scripts){ 
function print_scripts() { 
    wp_enqueue_script('jquery'); 
    } 
} 
add_action('wp_print_scripts', 'print_scripts'); 

// do the same for css 
if (! function_exists(print_styles){ 
function print_styles() { 
    wp_register_style('stylesheet', 'path to css'.stylesheet.css); //bloginfo(url); or something like it to obtain your path 
    wp_enqueue_style('stylesheet'); 
    } 
} 
add_action('wp_print_styles', 'print_styles'); 

它多一點的工作,但確保腳本和樣式得到正確插入,並在同一時間的wordpress選擇這樣做......

如果這是導致你的問題,我不積極,但它是一個很好的開始。