|
It's always better to specify the context. Especially when we have a heavy DOM.
|
|
|
|
|
All three examples you have given are using ID selectors[^]. Since each ID within the document should be unique, there's no point specifying the ID of the parent element, using the .find method, or passing the parent element with the selector.
With an ID selector, jQuery uses the document.getElementById function, which is extremely efficient. All of your examples will require additional checks, which will slow your code down.
Also, by specifying the parent element's ID, your script is now tied to the layout of your document.
Therefore, I would prefer option 4:
PriorityOfAccessModel:
{
Id: $('#Id').val(),
FamilyId: $('#FamilyId').val(),
ChildId: $('#ChildId').val(),
Comment: $('#Comment').val(),
CreatedBy: $('#CreatedBy').val(),
CreatedOn: $('#CreatedOn').val(),
Categories: accessPriority.getCategory(),
Allocating: { Id: allocating }
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
i am using jvector Map.its working well.now i want country details from database i have created simple database
1, canada, North America, None, Giovanni Facciponte, Approved
its my php file
close();
$query = "SELECT countryId, country, pdogcoregion, comments, ccl, category
FROM countrydetails
WHERE country='canada' ";
$countrydetails = '';
$stmt->bind_param('s', $countrydetails);
if ($stmt = $con->prepare($query)) {
$stmt->execute();
$stmt->bind_result($countryId, $country, $pdogcoregion, $comments, $ccl, $category);
while ($stmt->fetch()) {
}
$stmt->close();
}
?>
javascript ajax function:
$(document ).ready(function() {
$.ajax({
type: "GET",
contentType: 'application/x-www-form-urlencoded',
url: 'database.php',
data: {country: 'canada'},
dataType: "text",
success: function(data){
alert(data);
}
});
});
please what mistake there? please anyone find out my mistake ?
|
|
|
|
|
What doesn't work?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I am trying to validate file upload along with a few other form fields.
All the form fields listed in the script below are being validate except the single file upload.
Any ideas what I am doing wrong?
<script type='text/javascript' src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.js"></script>
script type='text/javascript'>//<![CDATA[
$(document).ready(function () {
// We'll use this flag so we don't have to validate fields before
// the form has been submitted.
var validatingForm = false;
// This line before validate() is called allows
// chosen menus to be validated
$.validator.setDefaults({ ignore: ":hidden:not(select)" });
$('#form1').validate({ // initialize the plugin
invalidHandler: function() {
// Now we can validate the fields onChange
validateForm = true;
},
rules: {
errorElement: 'div',
txtBidDate: "required",
txtDueDate: "required",
BidTitle: "required",
BidID: "required",
CategoryID: "required",
BidIDFile: "required",
AliasID: "required",
BidContact: "required",
ContactEmail: {
required: true,
email: true
},
BidType: {
required: true,
},
BidStatus: "required"
},
messages: {
txtBidDate: "Please enter Issue Date",
txtDueDate: "Please enter Due Date",
BidTitle: "Please enter Project Title",
BidID: "Please enter ID",
CategoryID: "Please select a Category",
BidIDFile: "Please select a Bid File",
AliasID: "Please select Department Alias",
BidContact: "Please enter Bid Contact",
BidTitle: "Please enter Project Title",
BidType: {
required: "Please select Bid Type"
},
ContactEmail: "Please enter a valid email address",
BidStatus: "Please select Bid Status"
},
});
// Now set an onChange event for the chosen menu
$("CategoryID").change(function(){
// Check that we've tried to submit the form
if(validateForm) {
// We tried to submit the form, re-validate on change...just to get rid of the message
$("CategoryID").valid();
}
});
$("AliasID").change(function(){
// Check that we've tried to submit the form
if(validateForm) {
// We tried to submit the form, re-validate on change...just to get rid of the message
$("AliasID").valid();
}
});
$("BidType").change(function(){
// Check that we've tried to submit the form
if(validateForm) {
// We tried to submit the form, re-validate on change...just to get rid of the message
$("BidType").valid();
}
});
$("BidStatus").change(function(){
// Check that we've tried to submit the form
if(validateForm) {
// We tried to submit the form, re-validate on change...just to get rid of the message
$("BidStatus").valid();
}
});
});//]]>
</script>
<input type="file" id="BidIDFile" name="BidIDFile[]" value="" size="50">
Thanks in advance for your prompt assistance.
|
|
|
|
|
I don't follow all your code but the likely reason is because the file upload control renders as separate html controls. You'll need to validate the actual textbox that get rendered client side.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
What a "fantastic" feedback!
Well, I fixed it myself and the problem was this BidIDFile[]
I played around and got it to work by using it like this:
"BidIDFile[]": "required" and it worked.
|
|
|
|
|
Good catch. This is mentioned in the documentation, but could probably be more prominent:
rules: ... Key is the name of an element (or a group of checkboxes/radio buttons), ...
So you have to use the name of the element, rather than its id .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
How to write the javascript function for pass image from set of image to another image box?
|
|
|
|
|
Do you mean how to load a image in Javascript, or how to accept one as a parameter in Javascript?
Because if you just want to load a image in Javacript you can do the following:
create a variable to hold the image like so: var Img = new Image();
then assign the src of the image like so: Img.src = "/PathToMyImage.jpg";
<-->
|
|
|
|
|
My requirement is to display thumbnail images on to my MVC view. What I am doing here is to convert image to byte array and convert them to base64 string and send this string back to JavaScript.
In JavaScript, I am assigning this base64 string to src attribute of image tag as below
$(img).attr("src", "data:image/png;base64," + data);
This process happened continuously 10 times in a for loop as I need to display 10 images in a page.
When I run this, I am getting half image in IE and showing nothing in Firefox. When I went into fire-fox console I am getting "Image is corrupted or truncated" exception and not sure what it is.
Could anyone throw some light on this issue?
If source code need for any of the said one, please let me know
|
|
|
|
|
I need a source of any simple game that is written with HTML as the front end and JAVA as the back end....
|
|
|
|
|
Please do not repost.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I need a game source code design with HTML as the front end and JAVA as the back end.....
|
|
|
|
|
Please search the Internet using google or some other search engine. No one is going to just hand you an entire game.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I guess you want to say 2 types...
|
|
|
|
|
Think again
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
|
Search in CodePlex or GitHub.
You will get a lot of stuffs of your need with proper documentation (almost).
Life is a computer program and everyone is the programmer of his own life.
|
|
|
|
|
|
So, I have this ajax that I'm writing to get the commit log from a private repo, and I'm planning to use my access token. So I thought, cool, I'll first use an authorized endpoint to get the token so I don't have to hardcode it into ajax.
Then I thought, well, wait, what's to stop someone from using the browser's developer tools to simply set a breakpoint and inspect the return value? Someone that is authorized, of course. I suppose that's a small layer of protection, but the question remains, how do I stop even someone authorized from seeing the access token when debugging the javascript?
Is that possible?
Marc
|
|
|
|
|
Your Access Token would be encrypted, right?
|
|
|
|
|
CodeReady wrote: Your Access Token would be encrypted, right?
No, because the access token has to be passed on to GitHub, not my own server.
Marc
|
|
|
|
|
Then I guess you can't do much about it and if you are getting token from the different server then its the server responsibility to encode it. One should not be worry about it cos generation and validation of the token will happen in github server.
|
|
|
|
|
I found many solution for this from my searches. But none worked. I have a page that is HTML, and one would think that JavaScript to do this would be simple and universally available. But, alas, that is not the case. Does anyone have a solution for this that works?
Bobby
|
|
|
|
|