Ever wanted a getJSON which does a post?
Here it is:
jQuery.extend({
postJSON: function(url, data, callback)
{
$.post(url, data, callback, "json");
}
});
Ever wanted a getJSON which does a post?
Here it is:
jQuery.extend({
postJSON: function(url, data, callback)
{
$.post(url, data, callback, "json");
}
});
Suppose you have a button named "submit":
<form method="post" action="" id="myForm"> <fieldset> <input type="text" name="myField" /> <input type="submit" name="submit" value="submit form" /> </fieldset> </form>
And you want to submit this form with jQuery:
<script type="text/javascript"> SomeFunction() { $("#myForm").submit(); } </script>
That won’t work since you have a button named ‘submit’ which then screws up the jQuery function. If you rename it to ‘submitForm’ or something it will work fine.
Die er niet is
Er is dus geen foreach in Javascript. Jammer want dit geeft meer obvious code:
String[] listNames = listViewNames.GetNames();
for(int x = 0; x < listNames.length; x++)
{
String name = listNames[i];
//do something with name
}
wordt...
String[] listNames = listViewNames.GetNames();
foreach(String name in listNames)
{
//do something with name
}
Er is wel een andere syntax voor het for statement, wat lijkt op foreach
var listnames = listViewNames.GetNames();
for(var index in listNames)
{
//i is now the index
var name = listNames[index];
//do something with name
}
Een extra stap dus, maar het kan handig zijn