2011-07-28 90 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选择这样做......

如果这是导致你的问题,我不积极,但它是一个很好的开始。