$.ajax({
method:"get",
url:"/details/",
data:"id="+id,
beforeSend:function(){
},
success:function(html){
$("#holder").html(html);
}
});
After I fill a div with a HTML from an AJAX call, this is my javascript at the top of /details/
<script type="text/javascript">
alert('hi');
</script>
MY DETAILS HTML CONTENT GOES HERE
But it's not working
Why I want to do this is another discussion entirely, but I need to figure out the best way to make all my alert dialogs have the positive button on the right side. Note that in version 3.0 and below the buttons normally appear as OK / Cancel and in 4.0 and above it is Cancel / OK. I want to force my application to use Cancel / OK in the simplest way possible. I have a lot of AlertDialogs in the application.
UCCN1003Edit
<script type="text/javascript">
$(function(){
$('a.edit').click(function(event){
var change = $(this).parent('div').find('p');
var changeText = change.text();
var wrapper = $(this).parent('div');
var clone = change.clone(true);
var changeBox = $(this).parent('div').find('.editBox');
var changeBoxText = changeBox.val();
if($(this).text() == 'Edit'){
wrapper.prepend("<input class='editBox' type='text' value='"+ changeText + "'/>");
wrapper.append("<a href='#' class='save' style='margin-left:10px' >Save</a>");
change.remove();
$(this).text("cancel");
}else if($(this).text()=='cancel'){
wrapper.prepend("<p>" + changeBoxText +"</p>");
$('.editBox').remove();
$('.save').remove();
$(this).text('Edit');
}
});
$('.save').click(function(event){
var editBox = $(this).parent('div').find('.editBox');
var editBoxText = editBox.text();
var wrapper = $(this).parent('div');
wrapper.prepand("<p>" + editBoxText + "</p>");
editBox.remove();
$(this).remove();
});
});
</script>
My part that work work is
$('.save').click(function(event){
var editBox = $(this).parent('div').find('.editBox');
var editBoxText = editBox.text();
var wrapper = $(this).parent('div');
wrapper.prepand("<p>" + editBoxText + "</p>");
editBox.remove();
$(this).remove();
});
where the wrapper wont prepand the p tag and the editBox and the .save wont be remove.
i try to add alert("work") in this and it wont alert at all. anyone know why?
Let's suppose I have button #click,
And suppose I bind the on click event as follows:
$('#click').click(function(){
alert('own you'+'whatever'+$(this).attr('href'));
});
But I want this to refer to some other element, let's say #ahref.
If it was a named function I would simply refer it by name:
foo.call('#ahref');
How could I use .call() though, if the function is called inline and does not have a name?
Is this a valid function pointer code below,
In views ,
def change(request):
dict={}
function_ptr="create()"
dict.update({'function_ptr' : function_ptr})
return render_to_response('mpjt/create.html',context_instance=RequestContext(request,{'dict': dict}))
In create.html
$(document).ready(function() {
var a = '{{dict.function_ptr}}'
func_ptr(a);
function create()
{
alert('got respponse');
}
});
Thanks..
I cant able to get this jquery statement to work on page load but it works once when i refresh F5 the page.....
<script type="text/javascript">
var itemsPerPage = 5;
$(document).ready(function() {
getRecordspage(0, itemsPerPage);
var maxvalues = $("#HfId").val();
alert(maxvalues);
$(".pager").pagination(maxvalues, {
//my syntax
});
});
</script>
On the initial pageload alert(maxvalues); is nothing... But when i refresh it shows the value of maxvalues which is in the hidden field HfId because it is assigned in the function getRecordspage....
Why this strange behaviour.... Any suggestion...
EDIT:
function getRecordspage(curPage) {
$.ajax({
type: "POST",
url: "Default.aspx/GetRecords",
data: "{'currentPage':" + (curPage + 1) + ",'pagesize':5}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(jsonObj) {
$("#ResultsDiv").empty();
$("#HfId").val("");
var strarr = jsonObj.d.split('##');
var jsob = jQuery.parseJSON(strarr[0]);
var divs = '';
$.each(jsob.Table, function(i, employee) {
divs += '<div class="resultsdiv"><br /><span class="resultName">' + employee.Emp_Name + '</span><span class="resultfields" style="padding-left:100px;">Category :</span> <span class="resultfieldvalues">' + employee.Desig_Name + '</span><br /><br /><span id="SalaryBasis" class="resultfields">Salary Basis :</span> <span class="resultfieldvalues">' + employee.SalaryBasis + '</span><span class="resultfields" style="padding-left:25px;">Salary :</span> <span class="resultfieldvalues">' + employee.FixedSalary + '</span><span style="font-size:110%;font-weight:bolder;padding-left:25px;">Address :</span> <span class="resultfieldvalues">' + employee.Address + '</span></div>';
});
$("#ResultsDiv").append(divs);
$(".resultsdiv:even").addClass("resultseven");
$(".resultsdiv").hover(function() {
$(this).addClass("resultshover");
}, function() {
$(this).removeClass("resultshover");
});
$("#HfId").val(strarr[1]);
}
});
}
How can I convert a JSON string to an object in JavaScript? Is there a method that does this?
Something like:
var x = "{ id: 5, name: 'hello' }";
var y = /*something*/(x);
alert(y.id + " " + y.name);
I need your help,
Given the html table below, how can I create a javascript function that will, at the click of a mouse, alert me the name of the column header?
Ie. if I click on the COLORS header, a javascript box will popup and alert("COLORS")?
<html>
<head>
</head>
<body>
<table border="1" cellspacing="1" width="500">
<tr>
<td>FRUITS</td>
<td>COLORS</td>
<td>VEGGIES</td>
<td>NUMBERS</td>
</tr>
<tr>
<td>apples</td>
<td>red</td>
<td>carrots</td>
<td>123</td>
</tr>
<tr>
<td>oranges</td>
<td>blue</td>
<td>celery</td>
<td>456</td>
</tr>
<tr>
<td>pears</td>
<td>green</td>
<td>brocoli</td>
<td>789</td>
</tr>
<tr>
<td>mangos</td>
<td>yellow</td>
<td>lettuce</td>
<td>098</td>
</tr>
</table>
</body>
</html>
This gives me auto: I need the number, so I can move one above the other?
// Swop div index
$("#panel div").each(function(){
alert($(this).css('z-index'));
});
I made a web application and I can connect to it some times from another pc on the same
wireless network
but if i tried to open it on the browser of N95 mobile it gives me alert of "system error"
is any one could make suggestions or tell me why
I turned firewall off
I use static IP for my pc
Here's my problem:
var slide;
$$('#slides li').each(function(i, n) {
slide = i;
setTimeout("initiateSlide()",n * 500)
});
function initiateSlide(){
i = slide;
alert(i); // pretty much alerts the last one 5 times
}
I expect to initiateSlide() with 5 different slides, instead I only get the last one 5 times.
$.getScript("somescript.js", function() {
alert('Load Complete');
});
Once loaded, is it cached or is it loaded again if referenced more than once?
If an event depends on this file being loaded, will the event be delayed of fail/timeout in case the file takes longer to load or doesn't load?
How do I check and do something in case the file fails to load for some reason?
Thanks in advance for your help.
I'm opening a sheet on a window , the first time the sheet opens
correctly, but if I close it, and try to open again it doesn't work, I
just get the system alert sound.
- (IBAction) showSpeedSheet:(id)sender
{
[NSApp beginSheet:addEditPackagePanel
modalForWindow:[[NSApp delegate] window]
modalDelegate:nil
didEndSelector:nil
contextInfo:nil];
}
-(IBAction)endSpeedSheet:(id)sender
{
[NSApp endSheet:addEditPackagePanel];
[addEditPackagePanel orderOut:sender];
}
I can't find what's wrong, the app doesn't print any error on the log.
For some reason, only in IE (tried 7 & 8), jQuery is performing a POST request when it should be a GET. See below:
function(...) {
/* ... */
$.ajax({
type: 'GET',
dataType: 'script',
url: '/something/' + id,
processData: false,
data: 'old_id=' + oldId,
success:function(data) {
alert(data);
}
});
/* ... */
}
All browsers properly GET, but IE is performing a POST. Why?
I wants to create an extension where content script will send message to background page and then on browser action means clicking on extension icon will access that background page and get some data.I am using chrome Version 23.0.1271.64 m on windows8.
I am getting following error.
Port error: Could not establish connection. Receiving end does not exist.
I tried to solve the same. but people are using sendRequest which is not supported by chrome20+. i also found solution mentioned for chrome 20+. But not working. Please help.
Below is the file contents.
manifest.json
{
"name": "Test Extension",
"version": "1.0",
"manifest_version": 2,
"description": "A test extension.",
"background": "background.html",
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["jquery.js","content.js"]
}
],
"permissions": ["tabs", "http://*/", "https://*/"],
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
}
}
background.html
<html>
<head>
<script src="background.js"></script>
</head>
<body>
<h1>Wy</h1>
</body>
</html>
background.js
chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
// Chrome 20+
alert(request);
console.log('received in listener');
sendResponse({farewell: "goodbye"});
});
content.js
$(function(){
console.log('start-sending message');
chrome.extension.sendMessage({greeting: "hello"},function(response){alert(response);});
console.log('end-sending message');
});
popup.html
<!doctype html>
<html>
<head>
<title>Getting Started Extension's Popup</title>
</style>
<!-- JavaScript and HTML must be in separate files for security. -->
<script src="jquery.js"></script>
<script src="popup.js"></script>
</head>
<body>
</body>
</html>
popup.js
$(function(){
var str_html = "<tr><td width='60%'>S</td><td width='40%'>15</td></tr><tr><td width='60%'>M</td><td width='40%'>25</td></tr>";
$('#sizes_container').html(str_html);
var bkg = chrome.extension.getBackgroundPage();
console.log(bkg);
});
Hello,
I am trying to get Marker data into hidden fields on my form. I'm not sure why this isn't working, it must be something in my js syntax:
var initialLocation;
var siberia = new google.maps.LatLng(60, 105);
var newyork = new google.maps.LatLng(40.69847032728747, -73.9514422416687);
var browserSupportFlag = new Boolean();
function initialize() {
var myOptions = {
zoom: 6,
mapTypeId: google.maps.MapTypeId.HYBRID
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
myListener = google.maps.event.addListener(map, 'click', function(event) {
placeMarker(event.latLng), google.maps.event.removeListener(myListener);
});
// Try W3C Geolocation (Preferred)
if(navigator.geolocation) {
browserSupportFlag = true;
navigator.geolocation.getCurrentPosition(function(position) {
initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
map.setCenter(initialLocation);
}, function() {
handleNoGeolocation(browserSupportFlag);
});
// Try Google Gears Geolocation
} else if (google.gears) {
browserSupportFlag = true;
var geo = google.gears.factory.create('beta.geolocation');
geo.getCurrentPosition(function(position) {
initialLocation = new google.maps.LatLng(position.latitude,position.longitude);
map.setCenter(initialLocation);
}, function() {
handleNoGeoLocation(browserSupportFlag);
});
// Browser doesn't support Geolocation
} else {
browserSupportFlag = false;
handleNoGeolocation(browserSupportFlag);
}
function handleNoGeolocation(errorFlag) {
if (errorFlag == true) {
alert("Geolocation service failed.");
initialLocation = newyork;
} else {
alert("Your browser doesn't support geolocation. We've placed you in Siberia.");
initialLocation = siberia;
}
}
function placeMarker(location) {
var marker = new google.maps.Marker({
position: location,
map: map,
draggable: true
});
map.setCenter(location);
}
}
var lat = latlng.lat();
var lng = latlng.lng();
document.getElementById("t1").value=lat;
document.getElementById("t2").value=lng;
<input type="hidden" name="lat" id="t1">
<input type="hidden" name="long" id="t2">
hi,
I'm using hillelcoren:AutoComplete component (hillelcoren.com/flex-autocomplete) in my Flex application.
It is really cool, however the text attribute doesn't work:
<hillelcoren:AutoComplete id="filterTag" dataProvider="{ dataManager.retrievedTagsList }"
labelField="name" keyUp="filterItems(filterTag.searchText)"
/>
while for the normal TextInput component it works:
<mx:TextInput id="filterTag" width="100%" keyUp="filterItems(filterTag.text)" />
1) I've tried keyUp="Alert.show(filterTag.searchText)" and I can read the text
2) I've tried filterItems(filterTag.text.toString())... still not working
3) the filterItems function works, because it works with a normal TextInput
thanks
How can i handle a link which doesn't have a id, it just has a classname like "classbeauty".
Now i need to know if a user has clicked the link.
If the link is clicked i just need to call the alert("yes link clicked");
I don't know how to handle events in Javascript.
How can i do that?
CODES:
$().ready(function(){
function sample()
{
alert("This is sample function");
}
$("#button").click(function(){
t=setTimeout("sample()",2000);
});
});
HTML:
<input type="button" name="button" id="button" value="Call sample function with delay">
Once i click button sample function is not called with a delay of 2 seconds. I dont know whats wrong. Please notify me how to do this
Question: To call javascript function using setTimeout via jquery
select @[email protected]('*')
for xml raw,type
Above statement will generate following alert:
Msg 6819, Level 16, State 3, Line 2
The FOR XML clause is not allowed in a ASSIGNMENT statement.
I have basically this on a page:
<script type="text/javascript">
function refresh_context() {
$("#ajax-context").html("Searching...");
$.get("/ajax/ldap_search.php", {cn: $("#username").val()}, function(xml) {
$("#ajax-context").html($("display", xml).text());
$("#context").val($("context", xml).text());
}, 'xml');
}
$(document).ready(function() {
$("#username").blur(refresh_context);
});
</script>
<input type="text" name="username" id="username" maxlength="255" value="" />
<input type="hidden" name="context" id="context" value=""/>
<div id="ajax-context"></div>
What it should do (and does fine on Firefox) is when you type a username in to the #username field, it will run /ajax/ldap_search.php?cn=$username, which searches our company's ldap for the username and returns it's raw context and a formatted version of the context like this:
<result>
<display>Staff -> Accounting -> John Smith</display>
<context>cn=jsmith,ou=Accounting,ou=Staff,ou=Users,o=MyOrg</context>
</result>
The formatted version (display) goes to the div #ajax-context and goes to the hidden input #context. (Also, the - are actually - "& g t ;" (without spaces)).
However, on IE the div stays stuck on "Searching..." and the hidden input value stays blank.
I've tried both .get and .post and neither work. I'm sure it's failing on the .get because if I try this, I don't even get the alert:
$.get("/ajax/ldap_search.php", {cn: $("#username").val()}, function() {
alert("Check");
});
Also, IE doesn't give me any script errors.
Edit: Added "$(document).ready(function() {", the .blur was already in it in my code, but I forgot to include that in my post.
Edit 2: The request is being sent and apache2 is receiving it:
10.135.128.96 - - [01/May/2009:10:04:27 -0500] "GET /ajax/ldap_search.php?cn=i_typed_this_in_IE HTTP/1.1" 200 69
I have the following:
$("span.findme").each(function() {
$("<li>").text($(this).text()).appendTo("ul");
});
How can I, using the above, detect if EACH finds 0, if it's 0 I want to trigger an alert.
Thanks
In Asp.net (c#),i'm not able to catch exception(FileNotFoundException) properly... i don't know the reason..Actually File s not there..But catch statement fails to catch the exception..
here is the code..
try
{
System.Drawing.Image imgg1 = System.Drawing.Image.FromFile(Server.MapPath("").ToString() + "\\images\\img1.jpg");
}
catch (FileNotFoundException)
{
Response.Write("<script>alert('Please Select and upload Student's Photo');</script>");
}