|
I have a doubt in ajax.My code is
function constructResponse( req , funName)
{
if (req.readyState == 4)
{
if (req.status == 200)
{
var callBackFunction = funName +"(request)";
var newFunction = new Function("request",callBackFunction);
newFunction(req);
}
else
{
alert("There was a problem in retrieving the data:\n" +req.statusText);
}
}
}
I call this function at req.onreadystatechange .My doubt is when else was called.Because most of the time i got the alert msg.How to avoid the alert.
Thx,
Muthu.N
|
|
|
|
|
You didn't share remaining code. onreadystatechange[^] is right one which have you used.
I think the problem occurs somewhere out of this code. What's the value of req object? What did you get from req.statusText ? Debug it, you could solve the issue.
Here Callback function[^] example from w3schools, check it out.
thatrajaNobody remains a virgin, Life screws everyone
|
|
|
|
|
I have a jQuery script that is listening for keydown on a textbox, like so:
$(document).ready(function () {
$("#result").on('keypress', function (e) {
...
});
});
My problem is that I have written this for a site architected and hosted by a 3rd party. This site allows you to move modules around the page if you wish.
When my module is moved (sometimes! not all the the time) it appears as if the page creates more instances of my code. As a result the code in the keydown function fires multiple times.
A few things:
1. I put an alert in the document.ready and can see it pop up multiple times, so I know the page it loading more instances of my javasvript.
2. When looking in the debugger in IE or Firefox I can't find more than one instance of the script, but a breakpoint on the one I can find will be caught only once. Whereas the code does run multiple time. Again and alert in the function can be seen multiple times.
I've tried unbinding events from my textbox before binding, but it doesn't work.
Does anyone have any ideas of how I can prevent my code from being instantiated or triggered multiple times?
|
|
|
|
|
You could have a look at what other events are firing when the stuff is moved around. You could then use these to suspend the kepress actions and then re-enable them post move.
|
|
|
|
|
I faced a similar situation when I had rendered the same parent script at multiple locations e.g. master / child pages and so on.
You may be facing a similar scenario.
|
|
|
|
|
I am no coding expert in any way, but I have coded a neat little thing to tell if a Node is up/down, I use some PHP script and chuck it into a table (It can be seen below, and yes , I know it is probably very messy, but I am new to this). I am now looking to add desktop notifications to tell the user when a Node pings back as down, and I understand that I will need to use JSON for this? But that is what I am stuck on. Do bear in mind that I already have a permissions code to ask for permissions to Enable Notifications :) www.samaustin.nn.pe/nitrostatus.php
= @fsockopen(="danger"
<td>1</td>
<td><i class="icon-remove-circle"></i> Node Down! We are working on this!</td>
</tr>';
} else {
echo '<tr class="success">
<td>1</td>
<td><i class="icon-ok-circle"></i> Node Up!</td>
</tr>';
}
?>
|
|
|
|
|
i have dynamically created drop down menus like.. name_1,name_2.. on add button's click event..
on click of save button i want to validate drop down like there is no same values in two drop down.. what should i do??
|
|
|
|
|
Use a common function that is executed when either dropdown value is changed. This function will compare the currently selected values in each of drop downs and alert the user in someone.
How you exactly do this is up to you, but start by looking at detecting a 'change' in the dropdowns
|
|
|
|
|
Validate dropdown change in jquery and display an appropriate message.
|
|
|
|
|
do you want to compare two drop down value should not be same?
|
|
|
|
|
Hi , i have a web method from which i am returning Date it is returning date like "Mon Sep 30 07:26:14 EDT 2013" now when i am converting formatt of date in my javascript code
var d= SomeDate.format("MM/dd/yyyy hh:mm:ss tt"); // Somedate is comming from web metghod
But in IE7(09/30/2013 04:56:14 PM) it is showing wrong Time but in IE9 (09/30/2013 07:26:14 AM)its working fine how can we do it in IE7
|
|
|
|
|
It seams like a time-zone problem...
IE9 shows EDT (UTC-4) and IE7 shows IST (UTC+5:30)...
Can you check the time-zone settings fro your machines?
Regards
Peter
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is (V).
|
|
|
|
|
|
I have my code structured in such a way that clicking on an 'Edit' button displays a hidden form (written in embedded ruby) within a 'div' html tag and within that form is a text_field_tag whose id is used to tie to a datepicker using Jquery.
Using my current view code and jquery datepicker code in rails : I can click on an edit button and select a date using the text_field_tag for each form. However, when I try to submit that datepicker value it only gets submitted for the first form (for the first 'td element).
Im guessing im doing something wrong with the Jquery code.Can anyone guide me as to how I can submit the datepicker value for the corresponding form (the closest form within 'td' on button click) as opposed to only submitting for the first form(first 'td' element)
Heres my code:
VIEW in RAILS:
<h2>Files</h2>
<table class="table">
<tr>
<th>Filename</th>
<th>Description</th>
<th>Download Link</th>
</tr>
<% <a href="/Members/files">@files</a>.each do |file| %>
<% filename = file.split('/').last %>
<% object = <a href="/Members/bucket">@bucket</a>.objects[file] %>
<tr>
<td><%= filename %></td>
<td>
<div class="file_description"><%= object.metadata['description']%>
<button id ="button1" type="button" class= "btn btn-default
edit_description" onclick="Window(this)">Edit</button>
</div>
<div id = 'hidden_form' class="file_description_update" >
<%= form_tag({:action => 'update_file_info'}, multipart: true) do %>
Update File Description: <%= text_area_tag :description %>
<%= hidden_field_tag :s3_path, file %>
<%= hidden_field_tag :prefix, <a href="/Members/prefix">@prefix</a> %>
<%= text_field_tag 'user_input' %>
<%= submit_tag 'Submit' %> </td> <br />
<% end %>
</div>
</td>
Code for Jquery in application.js file in Rails:
$(document).ready(function(){
$( "button.edit_description" ).on( "click", function( event ) {
$(this).closest('td').find("div.file_description_update" ).show();
$(this).closest('td').find("div.file_description_update"
).find('#user_input').datepicker();
});
});
|
|
|
|
|
Only one DOM element can have the same id (user_input in your case).
Remove id repetitions and add to your date input fields the same class name:
...
From this moment you can easily bind datepicker to all input elements by their common class:
$('input.dateinput').datepicker();
Or you can use input fields with "numerated" names like "name="date_1","date_2" etc.
and use jQuery selector like this:
$('input[name^=date_]').datepicker();
(^= means "name begins with ...)
|
|
|
|
|
how to get first and last date from selected month from dropdown selected value using javascript
ex:selected month is in format "september 2013"
i want first date and last date of this selected month
and same selected year.
|
|
|
|
|
The first day is always going to be 1
Every month almost has 31 days
You count your knuckles, forward and backwards
Jan = 31
Fed = 28
March = 31
April = 30
May = 31
June = 30
July = 31
Aug = 31
Sept = 30
oct = 31
Nov = 30
Dec = 31
You could of just Googled it on the interwebs
32 down vote accepted
Very simple, no library required:
var date = new Date();
var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
or you might prefer:
var date = new Date(), y = date.getFullYear(), m = date.getMonth();
var firstDay = new Date(y, m, 1);
var lastDay = new Date(y, m + 1, 0);
https://www.google.com/search?q=javascript%2C+get+month+strt+and+fish&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a#q=javascript,+get+month+start+and+finish+dates&rls=org.mozilla:en-US:official&spell=1[^]
|
|
|
|
|
Hello everyone! Please help me out of this stuff. I am trying to design a website(Live score site) that will prompt visitors to register or login before accessing the "LiveScore.html" page. The constraints I am having now are listed below:
1. How to connect the registration page to ms sql 2005 database with a table named VisitorsInfo,
2. How to save the registree info to the database with a table named VisitorsInfo,
3. And, how to query the database for visitors info when trying to login(if the visitor info is found, then access should be granted else denied). Note: visitors will login using passcode and email. I hope my explanations are clear. And also; I hope this can be achieved with javascript. Please any help will be welcome. Thanks alot in advance! Emmanuel.
|
|
|
|
|
|
Thanks! But, what do you me by this "veni, vidi, abiit donum? Sorry if it gets you angry. But I really want to know because you have used it in many post.
|
|
|
|
|
It's his signature, which is automatically appended to every post. It's Latin for, "I came, I saw, I went home".
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You're obviously a Classics scholar.
Veni, vidi, abiit domum
|
|
|
|
|
Either that or I can find my way to http://translate.google.com/[^]. The only Latin I know is "Romani ite domum".
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You mean you didn't translate Homer's words from the Attic Greek?
Veni, vidi, abiit domum
|
|
|
|
|
It's a different Homer[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|