|
I've had a go, doing some experiment over the weekend I found it was actually the key EvenListeners not firing. My website's a little mashed togeather due to time constraints so I figured I was going to take a step back and see what javascript / Jquery is running and what I can cut back.
Simon Lee Shugar (Software Developer)
www.simonshugar.co.uk
"You can be a king or a street sweeper, but everybody dances with the grim reaper" - Robert Alton Harris
|
|
|
|
|
0
I am trying to achive a ause functionality in javascript.
I am making an asynchronous AJAX call and trying to achive synhronous functionality of AJAX. I want to pause the javascript until i receive the AJAX response for the asyn call of AJAX. Due to some reason i am not using the AJAX synchronous call which will solve my problem.
Once i make a call i use the following two functions to pause the JS
function pause2(numberMillis) {
var dialogScript = "window.setTimeout(" +
" function () { document.write(' '); window.close(); }, "
+ numberMillis + ");";
var result = window.showModalDialog('javascript.document.writeln(' +
'"' + dialogScript + '<' + '/script>")');
}
function pause3()
{
do
{
if(lmsCommitTimeOut<9000){
lmsCommitTimeOut=lmsCommitTimeOut+1000;
pause2(1000);
}
else
{
//alert("TimeOut");
lmsCommitStatus="false";
return;
}
}while(readStateAchived=="false")
}
I call the pause3(); function which internally calls the pause2(1000) for every 1sec until i get the ajax response back, which i check with the help of a js variable "readStateAchived".
This is working well in IE6, but in IE7 it is poping up the modal window and not getting closed, I have to close it manually.
Can anyone help me with this?
Thank you.
|
|
|
|
|
Hello,
Tyr using jquery blockUI (v2.31) plugin instead. Before your AJAX call just use
$.blockUI({ message: '<h1><img src="busy.gif" /> Just a moment...</h1>' }); . More help can be obtained from here[^].
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|
0
I am trying to achive a ause functionality in javascript.
I am making an asynchronous AJAX call and trying to achive synhronous functionality of AJAX. I want to pause the javascript until i receive the AJAX response for the asyn call of AJAX. Due to some reason i am not using the AJAX synchronous call which will solve my problem.
Once i make a call i use the following two functions to pause the JS
function pause2(numberMillis) {
var dialogScript = "window.setTimeout(" +
" function () { document.write(' '); window.close(); }, "
+ numberMillis + ");";
var result = window.showModalDialog('javascript.document.writeln(' +
'"<script>' + dialogScript + '<' + '/script>")');
}
function pause3()
{
do
{
if(lmsCommitTimeOut<9000){
lmsCommitTimeOut=lmsCommitTimeOut+1000;
pause2(1000);
}
else
{
//alert("TimeOut");
lmsCommitStatus="false";
return;
}
}while(readStateAchived=="false")
}
I call the pause3(); function which internally calls the pause2(1000) for every 1sec until i get the ajax response back, which i check with the help of a js variable "readStateAchived".
This is working well in IE6, but in IE7 it is poping up the modal window and not getting closed, I have to close it manually.
Can anyone help me with this?
Thank you.
|
|
|
|
|
Hi , i Need TO customize the 'recordtext:{0}-{1}of {2}' in Jqgrid Using Jquery
I need Like this 1-10 of 29 (Users) ,
1-10 of 29 (Administrators) ,
1-10 of 29 (Emails)
In My project I am using Around 10 Jqgrids , i want to change the text inside the brackets for each single grid.
I need Urgent Solution .
The record text Format is in Language File of jqgrid(grid-en.js) and format like this 'recordtext:{0}-{1}of {2}'
|
|
|
|
|
|
hi,
I have looked all over and can't find something that suits my needs... so here goes...
I am creating a snooker game in HTML 5 canvas and JavaScript and have now came to the part of resolving the ball to ball collisions.
So far I have this, which is great, it detects the cue ball hitting another ball:
function isColliding(ball){
var distance = Math.sqrt(((this.posX - ball.posX)*(this.posX - ball.posX)) + ((this.posY - ball.posY) * (this.posY - ball.posY)));
if (distance < this.radius + ball.radius){
var collisionPointX = ((this.posX * ball.radius) + (ball.posX * this.radius)) / (this.radius + ball.radius);
var collisionPointY = ((this.posY * ball.radius) + (ball.posY * this.radius)) / (this.radius + ball.radius);
ball.speed = this.speed;
this.directionX = Math.cos(?);
this.directionY = Math.sin(?);
ball.directionX = Math.cos(?);
ball.directionY = Math.sin(?);
}
}
However I need to know how do I work out the Math.cos and Math.sin for the balls to move in a direction that is expected (using elastic collision), when they collide?
Thanks for help in advance..
Steve
|
|
|
|
|
I think you should have a look at the three top articles in the search below:
http://www.codeproject.com/search.aspx?q=snooker&x=0&y=0&sbo=kw[^]
In any case you should use vector calculus to calculate the angles as well as the elsatic collition. The Angles would be dependent on the incoming vector and the deviation should be from this line of reference. I know that the code is written in C# but I think you should get the understanding of the physics.
|
|
|
|
|
There are physics engines already implemented in JS
Physics Engine comparison
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
Did not know that.
|
|
|
|
|
Thanks
|
|
|
|
|
I m using the below code.But my page is taking much time to render.I m APS.net developer .Please suggest me solution.
function GetRecord() {
$.ajax({
type: "POST",
url: "abc.aspx/GetData",
data: "{NextPreviousYear:'" + parseInt($("#hdnNextPervious").val()) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccessCall,
error: OnErrorCall
})
}
function OnSuccessCall(response) {
$j(document).ready(function () {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var tblcalendar = xml.find("Report");
$('.tbl_calendar').html('');
$.each(tblcalendar, function (index) {
var row = "<tr>";
row += "<th>" + $(this).find("Month").text() + "</th>";
row += "<td class=" + $(this).find("D1").text() + "> </td>";
row += "<td class=" + $(this).find("D2").text() + "> </td>";
row += "<td class=" + $(this).find("D3").text() + "> </td>";
row += "<td class=" + $(this).find("D4").text() + "> </td>";
row += "<td class=" + $(this).find("D5").text() + "> </td>";
row += "<td class=" + $(this).find("D6").text() + "> </td>";
row += "<td class=" + $(this).find("D7").text() + "> </td>";
row += "<td class=" + $(this).find("D8").text() + "> </td>";
row += "<td class=" + $(this).find("D9").text() + "> </td>";
row += "<td class=" + $(this).find("D10").text() + "> </td>";
row += "<td class=" + $(this).find("D11").text() + "> </td>";
row += "<td class=" + $(this).find("D12").text() + "> </td>";
row += "<td class=" + $(this).find("D13").text() + "> </td>";
row += "<td class=" + $(this).find("D14").text() + "> </td>";
row += "<td class=" + $(this).find("D15").text() + "> </td>";
row += "<td class=" + $(this).find("D16").text() + "> </td>";
row += "<td class=" + $(this).find("D17").text() + "> </td>";
row += "<td class=" + $(this).find("D18").text() + "> </td>";
row += "<td class=" + $(this).find("D19").text() + "> </td>";
row += "<td class=" + $(this).find("D20").text() + "> </td>";
row += "<td class=" + $(this).find("D21").text() + "> </td>";
row += "<td class=" + $(this).find("D22").text() + "> </td>";
row += "<td class=" + $(this).find("D23").text() + "> </td>";
row += "<td class=" + $(this).find("D24").text() + "> </td>";
row += "<td class=" + $(this).find("D25").text() + "> </td>";
row += "<td class=" + $(this).find("D26").text() + "> </td>";
row += "<td class=" + $(this).find("D27").text() + "> </td>";
row += "<td class=" + $(this).find("D28").text() + "> </td>";
row += "<td class=" + $(this).find("D29").text() + "> </td>";
row += "<td class=" + $(this).find("D30").text() + "> </td>";
row += "<td class=" + $(this).find("D31").text() + "> </td>";
row += "</tr>";
$(".tbl_calendar").append(row);
});
});
}
function OnErrorCall(response) {
alert(response.status + " " + response.statusText);
}
Raj
ASP.net Developer
|
|
|
|
|
Haven't you spotted the spelling mistake?
hdnNextPervious *Previous*
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
I just spent another 5 minutes looking for it, and just caught it.
nice job dusty!
[edit]
Oh, I copied the mistake into my code sample, even worse!, oh well
|
|
|
|
|
I’m trying to get my website to show images one after the other using java script I got from www.javascriptkit.com/howto/show2.shtml and have followed there example as closely as I can but with no luck.
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Acrele - Home</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="CSS1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
var image1=new Image()
image1.src="16.jpg"
var image2=new Image()
image2.src="employee-training.jpg"
var image3=new Image()
image3.src="Real_Estate_Investment_Education.jpg"
var image4=new Image()
image4.src="Unti2tled.jpg"
var image5=new Image()
image5.src="Untitled.jpg"
var image6=new Image()
image6.src="zclassroom.jpg"
</script>
</head>
2. Added the html code were I want the image to show:
<div id="left-feature-colum">
<div id="slider-bg">
<div id="slider">
<img src="16.jpg" id="slide" width="600px" height="300px">
</div>
</div>
</div>
3. Edited there javascript accordingly to the number of images I’m using:
<div id="left-feature-colum">
<div id="slider-bg">
<div id="slider">
<img src="16.jpg" id="slide" width="600px" height="300px">
<script>
var step=1;
var img = document.getElementById('slide');
img.src = "image" + step + ".src";
console.log(img.src);
if (step < 6) step++;
else step = 1;
setTimeout(slideit, 3500);
</script>
</div>
</div>
</div>
This isn’t working, it only load the first image “16.jpg” only…Help
|
|
|
|
|
You have removed the code from inside the "slideit" function, so now there is no way for it to repeat and the setTimeout(slideit, 3500) is trying to call a function that doesn't exist.
|
|
|
|
|
There are a lot of bad slideshow scripts out there, I rewrote one that was a CMS plugin for word press which had many errors in it, and made no sense to me. It might be too advanced for you, and requires JQuery, but is simplistic in design.
[Display Advertising Filmstrip^]
|
|
|
|
|
you must use setinterval...
|
|
|
|
|
Your profile is not active so I'm can not know your name. I have a question ..
|
|
|
|
|
I have my account back now.
Also changed my profile to allow email replies.
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
<html>
<head>
<script type="text/javascript">
var rec = ["19","20","21","40","41","45","12","23","34","36","37","46"]
document.write("Weekly records for 2 week : ");
for(var i=0; i<12; i++) {
document.write(rec[i] + ",");
}
document.write("<BR>");
for(var z=0; z<6; z++) {
var q = Math.round(12 * Math.random());
document.write(rec[q], + "," + z);
}
</script>
</head>
<body>
</body>
</html>
I wrote a simple random permutations, but May Have NaN Error Can help me with this?
modified 25-Mar-13 3:23am.
|
|
|
|
|
Off by one error - range of random 0-12, valid range for Array 0 - 11
Removed an unwanted comma (,) after rec[q] in your document write.
<html>
<head>
<script type="text/javascript">
var rec = ["19","20","21","40","41","45","12","23","34","36","37","46"];
document.write("Weekly records for 2 week : ");
for(var i=0; i<12; i++) {
document.write(rec[i] + ",");
}
document.write("<BR>");
for(var z=0; z<6; z++) {
var q = Math.round(11 * Math.random());
document.write(rec[q] +", "+ z +" ");
}
</script>
</head>
<body>
</body>
</html>
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
Well.. now how do i prevent adding the numbers of array elements value, array elements only among themselves, I just wanted to combine random..
Output is:
19, 0 23, 1 20, 2 19, 3 34, 4 45, 5
it must be:
19, 23, 20, 19, 34, 45
Why does it wrote the numbers of random array and how do i prevent the same number selection..¿
Quickly remove the shameless
|
|
|
|
|
I have to special thanks for all ur helps.
|
|
|
|
|
Well you aren't putting the (value of) the z variable into the array. Only showing its value.
remove the
+ z +" " from document.write
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|