Put simply I have an ajax call that sometimes completes before the page is loaded, so I tried wrapping the callback in $( fn ), but the callback doesn't fire if the page is loaded... Anyone have a good solution to this?
$.get( '/foo.json', function( data ){
$( function(){
// won't get here if page ready beats the ajax call
// process data
$( '.someDiv' ).append( someData );
} );
} );
And yes, I know that if I flipped the order of those it would always work, but then my ajax calls would be needlessly deferred until the document is ready.
I have a code and the way it should work is,when they click on NEW CUSTOMER,it takes them to test1.php where in they enter the details and they hit submit.it saves all the details in properly in the database and when i go back and hit REFRESH ,it should come up with the customer details which they had entered in previously.
But what happens is, when i click on the REFRESH,it refreshes the same old page which is empty.I wanted to find out where am i missing the logic.Thanks in advance.
The sample code would be
<tr>
<td class="tdvisitbig" colspan="5">THIS IS A TEST</td>
</tr>
<tr>
<td class='tdvisitbig' colspan="5"><input type="button" onClick="openVisit('test1.php?id=<?=$key?>&name=<?=$name?>');return false;" value="NEW CUSTOMER" class="submit"> <input type="button" value="REFRESH" name="add_xyz" class="submit" onClick="document.add.target='_self';document.add.action='test3.php?redirect=visit§ion=test page';document.add.submit();"></td>
</tr>
<?
$q = "SELECT address,customernum,status FROM customer WHERE name='$name' ORDER BY customernum";
$r = mysql_query( $q , $Link );
while( $rw = mysql_fetch_assoc( $r ) )
{
extract( $rw );
?>
<tr>
<? } ?>
Hey guys,
I'm showing up veeeery long URLs in my Safari extension. Obviously, they can't fit on a single line. Currently, word breaking rules make it so most URLs are on two lines: the first one is rather short and ends with the ? symbol, and the other is ridiculously long and contains all the rest of the GET parameters.
I'd like to make it so words also break on the & symbol, without screwing up copy-paste if possible. I've tried to replace every & with &\u00ad (& + the soft hyphen character), but it's kind of weird to see the hyphen after the & when there really isn't any in the URL.
I thought there was something in store with CSS3 for that kind of problem, but I can't find it.
Any suggestion welcome, as long as it works with Safari.
So I've seen things like WordPress and FCKEditor, and basically a bunch of stuff that uses external code that I can't see or edit. Whenever I ask about editing and saving the content of a page in real time I just get referenced to an API or I get handed code that only changes the page until it's reloaded.
What I want to know is how do I code it myself? I want to add real time content editing to a page without the use of someone else's code. I've checked out code for various forums and wikipedia and whatnot, and all of it references code I don't have access to.
Is this a thing? Can I edit a page in real time? I thought of writing the edited text to a file on the server, and then when they click save, reading it back into the code to the section they were editing, but I don't know how to do that or if it's even possible.
As a side note, I'm very new to html, but not new to coding.
EDIT: The structure can be very much like Wikipedia, it doesn't have to be real time, it just has to work
I have created a html page in php and upon submission i validates that page using PHP. After validating i want to show an alert msg to show its status like showing any greeting or request for re-enter.
I have dont validation. Now i m using
header( 'Location: http://localhost/assignment/WebForm.htm' ) ;
to redirect user to same page but with a alert msg at page load or something like that. What I need to do ?
$('<a />').attr({
'href': '#'
})
.append(
$('<img />').attr({
'id' : 'img',
'src' : 'edit.png'
}))
.appendTo('body');
Is the the "right way" to go about adding <a href="#"><img src="edit.png" id="img" /></a> to the body?
Also how would I add some css onto the img?
http://jsfiddle.net/5DB6K/
I have this game being made where you shoot enemies from the sides of the screen. I've got the bullets moving and being removed when they reach the end of the screen (if they didn't hit any enemy) and removing the enemy when they collide with it.
//------------collision----------------//
if(shot === true){
bulletY = $('.bullet').position().top + 2;
bulletX = $('.bullet').position().left + 2;
$('.enemy').each(function(){
if($('.enemy').hasClass('smallEnemy')){
enemyY = $(this).position().top + 7;
enemyX = $(this).position().left + 7;
if(Math.abs(bulletY - enemyY) <= 9 && Math.abs(bulletX - enemyX) <=9){
$(this).remove();
score = score + 40;
bulletDestroy();
}
}
});
}
However, the bullet destroys every enemy if the collision check is right which isn't what I want. I want to check if the enemy has the class of either smallEnemy, medEnemy, or lrgEnemy and then do the collision check which is what I thought I had but it doesn't seem to work.
Also, the game starts to lag the more and more time goes on. Would anyone know the reason for that?
I put some jquery in my website that makes the text move to the right when the page changes. It works in Firefox and Safari but it doesn't work in Internet Explorer. My url to my website: http://katieduck.com/Courses/Improvisation%20Winter%20Course%20Dartington.html
Here is the code that is not working:
$(document).ready(function() {
$('#tabvanilla > ul').tabs({ fx: { height: 'toggle', opacity: 'toggle' } });
$('#featuredvid > ul').tabs();
});
Maybe you can find out what is wrong.
I have a page with several galleries including accordions and sliders. The problem is that the page takes forever to load. Is there a way of wrapping an image in a bit of code or applying a class to it to force it to load only after everything else is loaded?
Not sure if this is against stackoverflow rules as it's not a specific code question but I really need a little help.
I want to know if it is possible to create a search feature (search box) on an HTML webpage that will query a database and return the results?
Basically I have a database of products and their related categories. A user would come to the website, enter the category in the search field...somehow query the database and return the results on a new page.
Note: the results page doesn't have to be HTML (could be PHP etc).
If you could also include a little guidance on how (please nothing detailed, just need a direction).
Thank you!
i need to run this sql query , which give me a list of Id and Dates
i want to click each result and take with me the Id value to the next form
i wrote this query above but i see in the debager that the hidden ID get his value but not pass to the next form
i think i have a problem with the submit() .
where should i put him ?
thanks anat
function ShowAllCarts($user_email) {
$connB = new ProductDAO();
$connB->Connect();
$pro_query = "SELECT * FROM Cart WHERE `Email`='$user_email';";
$db_result = $connB->ExecSQL($pro_query);
$html_result = '<div data-role="content"> <ul data-role="listview" data-theme="b"> ';
$html_result .= '<form action="PreviouscartProduct.php" method="POST"/>';
while($row_array = $db_result->fetch_array(MYSQLI_ASSOC))
{
$Id= $row_array['Id'];
$Date= $row_array['Date'];
//$html_result //
$html_result .="<li><a href='PreviouscartProduct.php'>Cart number: $Id from Date: $Date><input type='hidden' name='Id' value'<?=$Id?>'</input></a></li>'";
$html_result .= '<a onclick="this.form.submit();" </a>;
}
$html_result .= ' </ul> </div>';
$html_result .= '</form>';
$connB->Disconnect();
return $html_result;
}
//display all carts
$func_result = ShowAllCarts($Email);
I'm looking for a jQuery function or plugin that serializes form inputs to an object using the naming convention for deep-serialization supported by param() in jQuery 1.4:
<form>
<input name="a[b]" value="1"/>
<input name="a[c]" value="2"/>
<input name="d[]" value="3"/>
<input name="d[]" value="4"/>
<input name="d[2][e]" value="5"/>
</form>
$('form').serializeObject(); // { a: { b:1,c:2 }, d: [3,4,{ e:5 }] }
Prototype's Form.serialize method can do exactly this. What's the jQuery equivalent? I found this plugin but it doesn't follow this naming convention.
I want to develop a extension for firefox. Now I add a image in my project, and I want to use it in my js.because my element is created dynamic,so I didn't get it from xul file. How to get the Image in JS directly?
Hello again,
I'm trying to loop through my totals in order to get a grand total for my web app. So far the code I am working with is the following:
function calcAllFields() {
var name = parseFloat($('div [name = total[]]').text());
var totArray = $.makeArray(name);
var total = 0;
for (var i = 0; i < totArray.length; i++) {
total += totArray[i];
}
$("#target1").text(total);
}
Instead of adding integers, something is being read as a string. Say I want to add 200 + 50, instead of 250 I get 20050. Could anyone please point out what I'm doing wrong? Thanks!
Hello,
I am trying to make a form dynamic using mootools 1.11, for specific reasons I cannot upgrade atm.
I'm trying to manipulate a select field to have dynamic options. This works in Firefox & Chrome but not IE8. Hope there's a fix for this.
bits of the code:
myOptions(hrs+1, 23, 'uur');
$('vertrektijd_uur').setHTML('<option value="">Kies uur</option>'+options_uur);
$('vertrektijd_uur').addEvent('change', function() {
hrsChanged = $('vertrektijd_uur').getValue();
hrsChanged = parseInt(hrsChanged);
if(hrs+1 == hrsChanged)
{
myMinutes(parseInt(min));
myOptions(minChanged, 55, 'min');
$('vertrektijd_min').setHTML('<option value="">Kies minuten</option>'+options_min);
}
else
{
myOptions(0, 55, 'min');
$('vertrektijd_min').setHTML('<option value="">Kies minuten</option>'+options_min);
}
});
{"paging": {"pageNum":2,"action":"Next","type":"","availableCacheName":"getAllFunds","selectedCacheName":"","showFrom":101,"showTo":200,"totalRec":289,"pageSize":100},
"Data":[{"sourceCodeId":0,"radio_fund":"individua
l","availableFunds":[],"fundId":288,"searchName":[],"fundName":"Asian Equity Fund A Class Income","srcFundGrpId":"PGI","firstElement":0,"las
tElement":0,"totalElements":0,"pageList":[],"standardExtract":true}]
I have json file with above format with two fileds,one paging and one is Data array.
I able to retrieve values of paging,but i am not able to retrieve the values of data array with .each function of jquery.
Any suggestions or inputs really appreciated.
Hi I am new to rails and would really appreciate some help, I am using the jQuery datepicker, the show view works however the index view doesn't, i get "undefined method `start_date' for nil:NilClass" in my index.html.erb file. Can you please let me know what is wrong with my index view and how i can fix it. The following are included in my app:
meetups_controller.rb
def show
@meetup = Meetup.find(params[:id])
end
def index
@meetups = Meetup.where('user_id = ?', current_user.id).order('created_at DESC')
end
show.html.erb
<h3>Title: <%= @meetup.title %></h3>
<p>Start date: <%= @meetup.start_date.strftime("%B %e, %Y") %></p>
<p>Start time: <%= @meetup.start_time.strftime("%l:%M %P") %></p>
<p>End date: <%= @meetup.end_date.strftime("%B %e, %Y") %></p>
<p>End time: <%= @meetup.end_time.strftime("%l:%M %P") %></p>
index.html.erb
<% if @meetups.any? %>
<% @meetups.each do |meetup| %>
<h3><%= link_to meetup.title, meetup_path(meetup) %></h3>
<p>Start date: <%= meetup.start_date.strftime("%B %e, %Y") %></p>
<p>Start time: <%= meetup.start_time.strftime("%l:%M %P") %></p>
<p>End date: <%= @meetup.end_date.strftime("%B %e, %Y") %></p>
<p>End time: <%= @meetup.end_time.strftime("%l:%M %P") %></p>
The existing site in cakephp with flash. We need to convert it into mobile version.
Please suggest me is there any possibilities for making mobile version.
I want to make it so that everytime you click on an 'h2' tag, the 'input' inside gets selected and the 'h2' tag changes background, but if another 'h2' tag is clicked, the current highlight and 'input' selection changes accordingly.
problem is that I have 3 different that do the same and with my code all the 3 forms are affected rather one. How do i limit my changes to only be contained to that form. Here is some code for clarification
'
<form>
...
<h2 onclick="document.getElementById(1001).checked='True'
$('h2').removeClass('selected');
$(this).addClass('selected');
">
CONTENT
<input type="radio" name="radio" id="1001" value="1001" />
</h2>
...
</form>
I have an image on the left hand side and text on right side. Like two column layout.
I want that when i scroll the text then the image should stay at center of page.
I tried using
position:fixed
But then the problem , sometimes when i resize the IE window to small size then the image stay at same position and it comes out of the main content area when i scroll down.
I want that image should scroll but should stay within the content area . It should not move outsid ethe main content aqrea
I have following function:
$('canvas').createWindow('xyz', 500, 600);
And js-code behind is:
var $ = function(element) {
if (this.constructor !== $) {
return new $(element);
}
alert(element);
var windowObj = document.getElementById(element);
this.createWindow = function(src, width, height) {
if(width != "" && height != "") {
windowWidth = windowObj.style.width = width + 'px';
windowHeight = windowObj.style.height = height + 'px';
}
};
};
But the problem is that JS says windowObj is null, alert(element) works fine! Thanks for your help!
I'm doing something terribly wrong and just can't find the solution for it.
Situation:
I've got a number of products with a number of quotes per product. Those quote automatically scroll in a div. If the scroll reaches the last quote is scroll back to the first one.
What works:
The function basically works when it's applied on 1 div, but when applied on multiple div it doesn't scroll back to the first one or keeps scrolling endlessly.
This is the function i've written for this:
function quoteSlide(divname){
$total = ($(divname+" > div").size())
$width = $total * 160;
$(divname).css('width', ($width));
console.log ($totalleft *-1);
if ($width - 160 > $totalleft *-1){
$currentleft = $(divname).css('left');
$step = -160;
$totalleft = parseInt($currentleft)+$step;
}else{
$totalleft = 0;
}
$(divname).animate(
{
left: $totalleft
}, // what we are animating
'slow', // how fast we are animating
'swing', // the type of easing
function() { // the callback
});
}
It's being executed by something like: quoteSlide('#quotecontainer_1'); in combination with a setInterval so it keeps scrolling automatically.
This is the jsFiddle where it goes wrong (So applied on more than 1 div) http://jsfiddle.net/FsrbZ/.
This is the jsFiddle where everything goes okay. (applied on 1 div)
When changing the following:
quoteSlide('#quotecontainer_1');
quoteSlide('#quotecontainer_2');
setInterval(function() {
quoteSlide('#quotecontainer_1');
quoteSlide('#quotecontainer_2');
}, 3400);?
to
quoteSlide('#quotecontainer_1');
setInterval(function() {
quoteSlide('#quotecontainer_1');
}, 3400);?
it does work... but only on 1 quotecontainer.
When I am trying to access Topspeed.com, my internet explorer shows the page just fine, but if I try firefox then I end up on the apache 2 test page... any idea why ?