开发者

PHP form conflicting with... something.

If I have the following code before &开发者_JAVA百科lt;/head> the php form sends but the css crashes and doesn't display the dropdown menu.

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

If I don't have the code, the submit button refreshes the page if blank and never sends anything but the dropdown menu works. If any of the fields are filled, the submit button returns with 404.

How can I keep both?

Additional details:

  • Wordpress CMS
  • The JQuery script was inserted in a field for customized js in WP.


I know JS is default, but try putting the type="text/javascript" in the <script> tag. Also, firebug for firefox has a NET tab that will most likely tell you what is going on. I would suggest if you can't figure it out by yourself, to post a screen shot of what is loading.


Wordpress can get finicky with manually embedded js and style embeds. The correct way to inject them is to add_actions to init, print_scripts and print_sytles. Add the following, or something like it to your 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');

Its a little more work, but ensures scripts and styles get inserted correctly, and at the same time wordpress chooses to do so...

I'm not positive if this is causing your issue, but its a great place to start.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜