JavaScript - Editing Jquery/ajax Effect
right now I almost have this script working the way I want it to, here it is:
Code: var hash = window.location.hash.substr(1); var href = $('.workimg a').each(function(){ var href = $(this).attr('href'); if(hash==href.substr(0,href.length-5)){ var toLoad = hash+'.html #selected'; $('#selected').load(toLoad) } }); $('.workimg a').click(function(){ var toLoad = $(this).attr('href')+' #selected'; $('#selected').slideUp('slow',loadContent); $('#load').remove(); $('#wrapper').append('<span id="load">LOADING...</span>'); $('#load').fadeIn('normal'); window.location.hash = $(this).attr('href'); function loadContent() { $('#selected').load(toLoad,'',showNewContent) } function showNewContent() { $('#selected').slideDown('slow',hideLoader); } function hideLoader() { $('#load').slideUp('slow'); } return false; }); How it works is an image is clicked, and it fills the #selected div with content. The problem I'm having is the #selected div is always visible so the questions I have are 1. How do I get this to snap to the #selected Div and add a 1 second delay before the slideDown effect? 2. How do I get add a fade in effect so it becomes Opacity=0 -> slideDown -> Opacity=1 when it appears and Opacity=1 slideUp -> Opacity=0 when it transitions to the next? Similar TutorialsHi, I'm looking to add the functionality of 'inline editing' with AJAX. I have found a good piece of code from a website (http://www.yvoschaap.com/weblog/ajax...pdate_text_20/) which does it well but I want to improve it slightly. I have a span tag with text in it which turns into an input box when a user clicks on the text. The user edits the input box and then click away from the input box in order to save the change and the input box turns back into regular text. How do i make it so when the person clicks on the text the input box appears but also an 'Update' and 'Cancel' link appears to the side of it so that the user can only update or cancel that field by clicking on the links. The code that does this is as follows: HTML CODE: Code: <span id="userName" class="editText">John Doe</span> JAVASCRIPT - controls when text is clicked for input to appear: Code: //edit field created function editBox(actual) { //alert(actual.nodeName+' '+changing); if(!changing){ width = widthEl(actual.id) + 20; height =heightEl(actual.id) + 2; if(height < 40){ if(width < 100) width = 150; actual.innerHTML = "<input id=\""+ actual.id +"_field\" style=\"width: "+width+"px; height: "+height+"px;\" maxlength=\"254\" type=\"text\" value=\"" + actual.innerHTML + "\" onkeypress=\"return fieldEnter(this,event,'" + actual.id + "')\" onfocus=\"highLight(this);\" onblur=\"noLight(this); return fieldBlur(this,'" + actual.id + "');\" />"; }else{ if(width < 70) width = 90; if(height < 50) height = 50; actual.innerHTML = "<textarea name=\"textarea\" id=\""+ actual.id +"_field\" style=\"width: "+width+"px; height: "+height+"px;\" onfocus=\"highLight(this);\" onblur=\"noLight(this); return fieldBlur(this,'" + actual.id + "');\">" + actual.innerHTML + "</textarea>"; } changing = true; } actual.firstChild.focus(); } JAVASCRIPT - Initiated the update of the field. Code: function fieldBlur(campo,idfld) { if (campo.value!="") { elem = document.getElementById( idfld ); remotos = new datosServidor; nt = remotos.enviar(urlBase + "?fieldname=" +escape(elem.id)+ "&content="+escape(campo.value)+"&"+formVars,""); elem.innerHTML = nt; changing = false; return false; } } I tried playing around to do it myself by adding an <a> link with an onclick event handler in the editBox() function ie. Code: onlick="noLight(this); return fieldBlur(this,'" + actual.id + "');" But i realise that the two values passed to the function need to be changed as i cannot use (this) if it's not within the input box? If anyone could help me with this query it would be greatly appreciated. I hope Ive given enough info and have expressed my problem clearly. If you have any questions let me know and I'll answer them ASAP. If you would like to see the whole source please go to the original website where i got it from - http://www.yvoschaap.com/weblog/ajax...pdate_text_20/ Thanks in advance Can some one help me step me through this last part of my script i have made. I have completed my entire chat program but currently i use: <meta http-equiv="refresh" content="5; URL=shout.php"> This is what keeps my chat room up to date, but this is pretty ugly due to the fact the browser makes a refresh. So i was hopeing some one could step my through to add ajax that makes a live affect with it appear to refresh. The script that has this chat is in the structure of: Code: <meta http-equiv="refresh" content="5; URL=shout.php"> <?php function get_chats(){ //query //while loop the logs out } getlogs(); ?> And thats it. I took a look on W3 about ajax and most of it was involve an event occuring such as submit/on key press which isn't what i want as some times a user may not do anything but i still want the chat to keep "up to date". I found one tutorial but it was over complicated to just take snippets out to put on my chat without knowing what it did or what to change for my chat to make it to work. Hope you can help - im a quick learner when i see the right example of what i need. I had a plugin created and the Jquery is not working correctly. Can anyone help me sort this out? I have exhausted all other options. Thanks. You can see this 'calendar' plugin here (near bottom of page): http://billboardfamily.com/blogs/ ISSUES: 1) The calendar sliding effect needs to be left/right as opposed to from the bottom. 2) 2 months should always be shown at all times 3) After you go through all months...it freezes completely 4) Is there anyone who can improve the navigation buttons? They are pretty weak at the moment. Here is the code: Code: <?php add_action('widgets_init', 'pc_widgets_init'); define('PCAL_CAT', 6); function pc_widgets_init() { register_widget('pc_widget'); } function get_post_calendar_html(){ global $wp_version; ?> <style type="text/css"> .wp-calendar{ width:160px;} .wp-calendar div.calendar {width:100%;} .wp-calendar caption { color:#48B05A; font-weight:bold; margin-bottom:6px; padding:0; text-transform:uppercase; font-size:.9em; text-align:left; } .wp-calendar tr {margin-bottom:0;} .wp-calendar td, .wp-calendar th.days {width:26px;height:26px;padding:0;margin:0 1px 1px 0;border:none;} .wp-calendar td.pad, .wp-calendar th.days {background-color:#eeeee7;} .wp-calendar th.days {text-align:center;padding-top:6px;height:20px;} table.mini {margin-right:-1px;} .wp-calendar td.view-item {margin:0; background-color:#d9d9cd; text-align:center;width:25px;height:20px; padding:6px;} .wp-calendar td.view-item a {text-align:center;padding-top:6px;color:#333;font-weight:bold;} .wp-calendar td.today {background-color:#48b05a;} .wp-calendar td.today a {color:#fff;} </style> <script type="text/javascript"> function pcal_prev(){ if(jQuery(".wp-calendar:visible").length > 1){ jQuery(".wp-calendar:visible:first").slideUp('slow'); jQuery(".wp-calendar:visible:last").next('.wp-calendar:hidden:first').show('slow'); } } function pcal_next(){ if(jQuery(".wp-calendar:visible:first").prev('.wp-calendar:hidden').length){ jQuery(".wp-calendar:visible:last").hide('slow'); jQuery(".wp-calendar:visible:first").prev('.wp-calendar:hidden:last').show('slow'); } } </script> <span class="calendar_nav_bar"><a onclick="pcal_next()"><—</a> <span><?php echo $browse; ?></span> <a onclick="pcal_prev()">—></a> </span> <?php pcal_get_posts(); } function pcal_get_posts(){ global $wpdb, $wp_locale; $thisyear = gmdate('Y', current_time('timestamp')); $thismonth = gmdate('m', current_time('timestamp')); $lastmonth = $thismonth-1; $lastyear = $thisyear; if($thismonth == -1){ $lastmonth = 12; $lastyear -=1; } get_post_calendar($thismonth,$thisyear); // Get months this year and next with at least one post $future = $wpdb->get_results("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year FROM $wpdb->posts WHERE post_date <='$lastyear-".($lastmonth+1)."-01' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC"); $x= 0; //Hide counter, after the first one, it will disappear foreach($future as $now){ get_post_calendar($now->month,$now->year,$x); $x++; } } // Calendar Output... function get_post_calendar( $thismonth ='', $thisyear='', $hide=0) { global $wpdb, $timedifference, $wp_locale; $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); // week_begins = 0 stands for Sunday $week_begins = intval(get_option('start_of_week')); $add_hours = intval(get_option('gmt_offset')); $add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours)); if($hide) $style = "display:none;"; echo '<table class="wp-calendar" style="'.$style.'"> <caption>' . $wp_locale->get_month($thismonth) . ' ' . $thisyear . '</caption> <thead> <tr>'; $myweek = array(); for ( $wdcount=0; $wdcount<=6; $wdcount++ ) { $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7); } foreach ( $myweek as $wd ) { $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" class='days' title=\"$wd\">$day_name</th>"; } echo ' </tr> </thead> <tbody> <tr>'; // Get days with posts $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships AS trel ON ($wpdb->posts.ID = trel.object_id) LEFT JOIN $wpdb->term_taxonomy AS ttax ON ( trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN $wpdb->terms AS tter ON (ttax.term_id = tter.term_id) WHERE MONTH(post_date) = '$thismonth' AND YEAR(post_date) = '$thisyear' AND post_type = 'post' AND post_status = 'publish'" ."AND post_type = 'post' AND post_status = 'publish' AND ( ttax.taxonomy = 'category' AND $wpdb->posts.ID = trel.object_id AND trel.term_taxonomy_id = ttax.term_taxonomy_id AND ttax.term_id = tter.term_id AND tter.term_id = '".PCAL_CAT."')", ARRAY_N); if ( $dayswithposts ) { foreach ( $dayswithposts as $daywith ) { $daywithpost[] = $daywith[0]; } } else { $daywithpost = array(); } if ( strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') ) $ak_title_separator = "\n"; else $ak_title_separator = ', '; $ak_titles_for_day = array(); //sets the Density Thermometer $ak_posts_for_day = array(); $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom " ."FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships AS trel ON ($wpdb->posts.ID = trel.object_id) LEFT JOIN $wpdb->term_taxonomy AS ttax ON ( trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN $wpdb->terms AS tter ON (ttax.term_id = tter.term_id) " ."WHERE YEAR(post_date) = '$thisyear' " ."AND MONTH(post_date) = '$thismonth' " ."AND post_type = 'post' AND post_status = 'publish' AND ( ttax.taxonomy = 'category' AND $wpdb->posts.ID = trel.object_id AND trel.term_taxonomy_id = ttax.term_taxonomy_id AND ttax.term_id = tter.term_id AND tter.term_id = '".PCAL_CAT."')" ); // print_r($wpdb); if ( $ak_post_titles ) { foreach ( $ak_post_titles as $ak_post_title ) { if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) $ak_titles_for_day['day_'.$ak_post_title->dom]['title'] = ''; if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ){ // first one $ak_titles_for_day["$ak_post_title->dom"]['title'] = str_replace('"', '"', wptexturize($ak_post_title->post_title)); $ak_titles_for_day["$ak_post_title->dom"]['id'] =$ak_post_title->ID; }else{ $ak_titles_for_day["$ak_post_title->dom"]['title'] .= $ak_title_separator . str_replace('"', '"', wptexturize($ak_post_title->post_title)); } $ak_posts_for_day["$ak_post_title->dom"] +=1; } } // See how much we should pad in the beginning $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins); if ( 0 != $pad ) { echo "\n\t\t".'<td colspan="'.$pad.'" class="pad"> </td>'; } $daysinmonth = intval(date('t', $unixmonth)); for ( $day = 1; $day <= $daysinmonth; ++$day ) { if ( isset($newrow) && $newrow ) echo "\n\t</tr>\n\t<tr>\n\t\t"; $newrow = false; if ( $day == gmdate('j', (time() + (get_option('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_option('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_option('gmt_offset') * 3600)) ){ echo '<td class="today view-item">'.'<span>'.$day.'</span>'; }elseif(in_array($day, $daywithpost)){ echo '<td class="haspost view-item">'; echo '<a href="'.get_permalink($ak_titles_for_day[$day]['id'] ).'" title="'.$ak_titles_for_day[$day]['title'].'" '.$onclick1.' >'.$day.'</a>'; }else{ echo '<td class="view-item">'.'<span>'.$day.'</span>'; } // any posts on that day? if ( in_array($day, $daywithpost) ) { //Outputs the Density Thermometer along with the day... } else { } echo '</td>'; if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) ) $newrow = true; } $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins); if ( $pad != 0 && $pad != 7 ) echo "\n\t\t".'<td class="pad" colspan="'.$pad.'"> </td>'; echo "\n\t</tr>\n\t</tbody>\n\t</table>"; } /*Add Dashboard Widget via function wp_add_dashboard_widget()*/ function pc_setup_dashboard_widget() { wp_add_dashboard_widget( 'pc_add_dashboard_widget', __( 'Posts Calendar' ), 'pc_add_dashboard_widget' ); } function pc_add_dashboard_widget(){ pcal_getposts(0); } class pc_widget extends WP_Widget { function pc_widget() { $widget_ops = array('classname' => 'pc_widget', 'description' => __( "Show your blog's Future Posts in the sidebar.") ); echo $this->WP_Widget('pc_widget', __('Posts Calendar Sidebar'), $widget_ops); } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['browse'] = strip_tags($new_instance['browse']); $this->flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['pc_widget']) ) delete_option('pc_widget'); return $instance; } function flush_widget_cache() { wp_cache_delete('pc_widget', 'widget'); } function form( $instance ) { $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; $title = isset($instance['browse']) ? esc_attr($instance['browse']) : ''; ?> <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title'); ?></label> <input type="text" name="<?php echo $this->get_field_name('title'); ?> id="<?php echo $this->get_field_id('title'); ?>" value="<?php echo $title;?>"> <p><label for="<?php echo $this->get_field_id('browse'); ?>"><?php _e('"Browse Post" text'); ?></label> <input type="text" name="<?php echo $this->get_field_name('browse'); ?> id="<?php echo $this->get_field_id('browse'); ?>" value="<?php echo $browse;?>"> </p> <?php } function widget($args, $instance) { global $wpdb; $cache = wp_cache_get('pc_widget', 'widget'); if ( !is_array($cache) ) $cache = array(); if ( isset($cache[$args['widget_id']]) ) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('Scheduled Posts') : $instance['title']); $browse = empty($instance['browse']) ? __('Browse Posts') : $instance['browse']; ?> <?php echo $before_widget; ?> <?php echo $before_title; ?><?php if ( $title ) echo $title; ?><?php echo $after_title; ?> <div id="pc"> <?php get_post_calendar_html();?> </div> <?php echo $after_widget; ?> <?php $cache[$args['widget_id']] = ob_get_flush(); wp_cache_add('pc_widget', $cache, 'widget'); } } ?> Gljpartners.com this site has a interesting scrolling feature. for the images.. does anyone know how it's done? I have made myself an HTML Menu which is located on top of my current Flash object. I have a question whether it really is not possible to get the same effect as 'text' has on the original "Flash Menu" EX: www.moebelarkitekten.dk and get the same effect over at my new HTML menu (Coded with Jquery) EX: http://www.richyjassal.co.uk/moebelar/ Right now it is almost the same effect, but only: OnMouseOver align text to Right OnMouseOut text to align left A guide, or other? Hey everyone, I'm a NOOB, yeah, its hard at the beginning but you have to start somewhere right? Anyway I'm currently building a website that incorporates JavaScript, ActionScript, and the usual CSS and XHTML, but I've run into a bit of a snag. Our wishes for this grass roots web page was to add Ariel Flesler's ScrollTo jQuery plugin to our navigation, to dynamically slide our entire pages from left to right, right to left, upon the users choice. But, our navigation buttons, on our homepage in particular, are within a SWF file. Now is it possible to trigger the ScrollTo effect from buttons within a SWF? If not, can you provide a alternate solution to this dilemma? Thank you all, and I'm happy to be a new student of this community. so i have this "class" defined in a javascript file, "a.cross-link". This enables the ability for users to navigate the webpage in a slider format. it works fine if I directly place the required html code: Code: <a class="cross-link" href="#3" title="Go to Page 2">View Results</a> but if i have php print out that line for me, it doesn't work: PHP Code: echo "<a class= \"cross-link\" href=\"#3\" title=\"Go to Page 3\">$name</a>";( Where $name is some variable) Note: the php code is just your average sql stuff. here is an interesting observation i've made: if i "hardcode" this this into the html: <a class="cross-link" href="#3" title="Go to Page 3">View Results</a> and then i go to generate the sourcecode, this is what appears (this works): <A class=cross-link title="Go to Page 3" href="#3" jQuery1283131847233="30">View Results</A> but if i have the html made by a php echo statement, it just stays the same - i dont get a jQuery1283131847233="30" generated in the sourcecode. i'm sorry i'm having difficulty describing the problem. i'm new to jquery and ajax stuff. to me, it seems like the "cross-link" class i have defined in the javascript isn't being applied to correctly. i have no idea. can you invoke javascript from a php echo statement that is formatted to produce html code? here is another thing i believe is true: when the page loads, the javascript loads. the users, through the use of ajax, submitts a sql querey and navigates, using a jquery slider, to another div (where i want the user to go after selecting a resulting link from the sql query). so the javascript is going to execute before the list of results is produced. do I need to rerun the javascript each time new php produced sql data is populated in a div? if so, how? i dont know what more information you may need, so please ask. Thanks. I have a page that has a simple AJAX call that works fine in firefox and chrome but not in ie. In IE my loading image shows up but the actual sourceURL never loads or shows. Below is my html and javascript code. Can anyone help me with this? <div id="design_strap" style="display:none"> <a href="javascript:loadContent('#content', 'strap.html');">Link</a> <div id="content"></div> </div> <script type="text/javascript"> $.ajaxSetup ({ // Disable caching of AJAX responses cache: false }); function loadContent(elementSelector, sourceUrl) { $(""+elementSelector+"").html('<p><img src="images/loading.gif" width="150" height="150" /></p>'); $(""+elementSelector+"").load(""+sourceUrl+""); //$("content").height(350); } </script> i have made one page this is page link http://pickthefights.com/fantansy-fi...482&page=fight the code of this page is this <script type="text/javascript"> //////////////////////////////// // // Refreshing the DIV FANBOO2 // //////////////////////////////// function refreshdiv_fanboo2(){ // Customise those settings var seconds = 1; var divid = "fanboo2"; var url = "http://pickthefights.com/fanboo2/?id=<?php echo $idvar ?>"; // Create xmlHttp var xmlHttp_two = AJAX(); // No cache var timestamp = fetch_unix_timestamp(); var nocacheurl = url+"?t="+timestamp; // The code... xmlHttp_two.onreadystatechange=function(){ if(xmlHttp_two.readyState==4){ document.getElementById(divid).innerHTML=xmlHttp_two.responseText; setTimeout('refreshdiv_fanboo2()',seconds*1000); } } xmlHttp_two.open("GET",nocacheurl,true); xmlHttp_two.send(null); } // Start the refreshing process window.onload = function startrefresh(){ setTimeout('refreshdiv_fanboo2()',seconds*1000); } </script> <script type="text/javascript"> refreshdiv_fanboo2(); </script> <div name="fanboo2" id="fanboo2"></div> now what ever i put in fanboo2 page it works fine but javascript or jquery is not working here is code of fanboo2 page, you can check page here http://pickthefights.com/fanboo2/?id=482# here is it is working but not here http://pickthefights.com/fantansy-fi...482&page=fight </script> <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script> <script src="http://bxslider.com/sites/default/files/jquery.bxSlider.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $('#slider1').bxSlider(); }); </script> <ul id="slider1"> <li>Slide one content</li> <li>Slide two content</li> <li>Slide three content</li> <li>And so on...</li> </ul> please help me out i want to make java script work on both of this page I'm updating a database w/o "reloading" the page using jquery & ajax. Everything works fine, but I need to display an error (in php - mysql_error()) in the error callback function. I also don't think that the success/error callbacks are working as even when I changed the password in to the mysql server in the php file, I got the success message :S Can any1 help me out? this is the php script Code: <?php /*$fp = fopen('data.txt', 'a+'); fwrite($fp, 'ok'); fclose($fp);*/ $sections = $_REQUEST['sections']; $fontColor = $_REQUEST['fontColor']; $bgcolor = $_REQUEST['bgcolor']; $font = $_REQUEST['font']; $fontSize = $_REQUEST['fontSize']; $lineHeight = $_REQUEST['lineHeight']; $letterSpacing = $_REQUEST['letterSpacing']; $fontStyle = $_REQUEST['fontStyle']; //$tekst = $_REQUEST['tekst'] $connect = mysql_connect("localhost", "root", "password") or die ("Unable to connect to the database"); mysql_select_db("ipsum") or die ("doesnt exist: " . mysql_error()); $update = "INSERT INTO con (Sections, Fontcolor, BackgroundColor, Font, FontSize, LineHeight, LetterSpacing, FontStyle) VALUES ('".$sections."', '".$fontColor."', '".$bgcolor."', '".$font."', '".$fontSize."', '".$lineHeight."', '".$letterSpacing."', '".$fontStyle."')"; // the content of 'data.txt' is now 123 and not 23! mysql_query($update) or die ("unable to update: " . mysql_error()); mysql_close($connect); ?> and this is what I currently have for the error Code: error: (function (){$('#errorMessage').fadeIn("slow").delay(1000).fadeOut(2000);}), but that needs to change... I want to pass the "divId' function so that i can grab functions dynamically into the server where "success" is. this possible? I know the current setup is not (because " d.divId " isn't a variable) Code: function run(times,divId) { $(function() { var client_id = $('#client_id').attr('value'); $.ajax( { url:'http://urlhere.com', data:{c:client_id}, timeout:99999999999999, dataType:'jsonp', jsonp:'callback', jsonpCallback:'jsonpCallback', error:function() { if (times==1) { run(2); } else { $('#'+divId).html('Error') } }, success:function(d) { $('#'+divId).html('$'+d.divId); } }); } I am trying to perform an AJAX lookup during form validation onsubmit. It is important that it takes place during submit, but it seems to always return true and allow the form to post even when it should not. I have tried putting the AJAX portion in its own function and having it return true or false to the validation function but also does not seem to work. Here is what the code looks like... Code: $("#companyform").submit(function() { $.ajaxSetup({ cache: false }); $.post("ajax_v2Functions.cfm", { coNum: $("#companyNumber").val() }, function(response) { if(response != "") { alert("That company number is already in use by " + response); $("#companyNumber").focus(); return false; } return false; } , "html"); if($("#companyname").val() == "") { alert("The company name cannot be left blank."); $("#companyname").focus(); return false; } if($("#companyNumber").val() == "") { alert("The company number cannot be left blank."); $("#companyNumber").focus(); return false; } }); Hi there, I am trying to make a view that stacks images on top of one another. As the user uses mouseup or mousedown (+ LMB click) the user can scroll through the images. I am trying to use Ajax to load the new image when the user mousesup. RIght now nothing happens on mouseup. Can someone tell me what I am doing wrong please? thank you. FYI: no errors on Firebug, hence I am posting here. Code: $("#filmviewer").mouseup(function(){ alert("t"); }); html Code: <div id="filmviewer" style="width:400px;"> <img src="pic_1.jpg" /> </div> The problem is when I click and mouseup over the image the alert("t") does not fire. what am I doing wrong? Hey guys I should preface this by saying that this is not for my own site, or my own code; a friend has gone on holiday and needed this project fixing while he was away. Unfortunately my experience with jQuery is almost nil and everything was coded by someone else, so I'm really tearing my hair out. This is a Wordpress installation running Thematic with two child themes, one of which uses Ajax calls to grab page content. The issue is that the Ajaxified calls stop the swfObject content from being loaded. Compa http://dev.segolondon.com/wp292/media/ <- Flash content loads versus: http://dev.segolondon.com/wp292/#wp292/media/ If you take a look at the code of the two pages, you'll see there are no swfobject.embedSWF() calls on the Ajaxified page. It seems as though the jQuery calls are pre-empting the JS/Flash detection, so the swfObject code is never even written to the page. The actual custom, handwritten code (i.e. not from a library or a plugin) on this site is minimal, so I'm grasping at straws to fix this. I read somewhere about using a script block like this: Code: <script> $(document).ready( function() { // Make the swfObject call } ); </script> But I'm not really sure where to put it since there are so many plugins used, all with slightly different embed methods. Any help would be very gratefully received! function sendValues() { var str = $("#myForm").serialize(); $.ajax({ type: 'POST', url: "/trying.php?avoidcache=' + myTimestamp();", data: str, cache: false, return:false }); } $(":checkbox[name='brand[]']").click(function() { $("#myForm").submit(); }); ..Upon reload, the values are serialized.. But when the page is done loading..the chosen values (checkbox) is not checked, I need it stay checked so I can add other values via checkbox to the url. here is a live demo.. http://vbizmarketing.com/trying.php Please help. I'm make a ajax call to a processing PHP file that echos either "success" or an "error message". When the success is returning, i want Jquery to recognize this and then redirect the browsers instead of displaying the success message. Here are some snippets. I can only seem to parse to a blank or null. Jquery code: Code: $.ajax({ type: "POST", url: "process.php", data: wfLoginPost(), success: function(msg){ alert(msg); // both below are either null or blank //var res = $(msg).find("span.response").text(); //var res = $(msg).find("span.response").html(); if(res == 'Success'){ window.location = 'http://www.google.com'; } } }); process.php PHP Code: if($qry[0]['pwd'] == $password){ echo "<span class='response'>Success</span>"; }else{ echo "<span class='response'>Username or password did not match</span>"; } Here is the contents of the msg response from the ajax post: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href="css/reset.css"/> <link rel="stylesheet" type="text/css" href="css/960grid.css"/> <link rel="stylesheet" type="text/css" href="css/style.css"/> <link rel="stylesheet" type="text/css" href="css/statusmessageQ.css"/> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.statusmessageQ-0.5.js"></script> </head> <span class='response'>Success</span> I have a problem where the page doesn't expand when more results get loaded via jquery on a facebook style wall. Once more results get loaded the footer stays static instead of moving down. What's the best way to do this? All, I currently have this code to make a post to my database: Code: var $dataString = 'name='+ $name + '&black_white=' + $black_white + '&color=' + $color + '&color=' + $other + '&other_text=' + $text; $.post("save_edits.php", {image_save_string: $dataString}, function(result) { $("#multiple_images").hide(); $("#result_success").html("<font color='red'>We've successfully saved your photo edits!</font><br><br>"); $("#image_divs").html(result); }); Within the result I'm actually recreating the form for them to use if they want. I have a decent amount of jQuery that got initialized when the original page was loaded. Once I get my new form it doesn't work because it wasn't originally included in the page initialization. Is there a way just to call the document.ready function again to have it reinitialize my form elements again? Thanks in advance. What would be the best way to get data for a mobile site. I've tried using Jquery $.ajax to bring in the data from a php file. It seems to work however it takes some time to load without a way to really give a progress meter. I was wondering what the fastest way to do this would be. For instance it loads and loads then after a long while the alert(); pops up and the data loads into the page. Ultimately i was thinking i could use the ajax request to read in the data from the mysql database server, then transfer it to localstorage, im using HTML5 primarily for the development also just for reference. Somewhat new to mobile development i was just wondering if anyone had a starting point for me to look at and go from there. Code: $(document).ready(function($){ var dataret = 0; $.ajax({ type: 'POST', url: 'mobile.php', beforeSend: function(){ $('#status').show(); }, success: function(data){ //initialize localstorage here alert('success'); // if it takes as long as it does, a few minutes, at least show a loading bar... $('#progress').progressbar({ }); }, dataType: 'json' }); }); Thanks in advance! So, i have this code which retrieves php files for me using jquery and id love to get it working with Jquery history plugin. I tried modifying the code i got from the ajax demo to work for me, but i just couldnt do it as i do not know any javascript really.. ( actually what i tried was simply to change "#ajax-links a" to "#menu li a" and .html to .php ..but nothing.. :rolleyes: Id be very gratefull if someone would help me out with this one. All related code can be found bellow (the ones that should be needed anyways): This is the code that retrieves php files inside "#content" when item from "#menu li a" with the specified id is clicked Code: $(document).ready(function(){ //References var change = $("#menu li a"); var loading = $("#loading"); var content = $("#content"); //Manage click events change.click(function(){ //show the loading bar showLoading(); //load selected section if(this.id == "home") { change.load(this.className='current-page'); content.slideUp(); content.load("pages/index.php", hideLoading); content.slideDown(); } else if(this.id == "secondpage") { change.load(this.className='current-page'); content.slideUp(); content.load("pages/secondpage.php", hideLoading); content.slideDown(); } else { //hide loading bar if there is no selected section hideLoading(); } }); //show loading bar function showLoading(){ loading .css({visibility:"visible"}) .css({opacity:"1"}) .css({display:"block"}) ; } //hide loading bar function hideLoading(){ loading.fadeTo(1000, 0); }; }); Heres the structure of the menu/content Code: <ul id="menu"> <li><a id="home" class="normal" href="#Home"></a></li> <li><a id="secondpage" class="normal" href="#Secondpage"></a></li> </ul> <div id="content"> <ul id="sec-menu"> <li><a id="link1" class="normal" href="#">Link1</a></li> <li><a id="link2" class="normal" href="#">Link2</a></li> </ul> </div> Heres the code that jquery history plugin uses in demo for ajax Code: jQuery(document).ready(function($) { function load(num) { $('#content').load(num +".html"); } $.history.init(function(url) { load(url == "" ? "1" : url); }); $('#ajax-links a').live('click', function(e) { var url = $(this).attr('href'); url = url.replace(/^.*#/, ''); $.history.load(url); return false; }); }); |