Search Results

Search found 4827 results on 194 pages for 'alert'.

Page 21/194 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • how to get a value which points to a function

    - by darkandcold
    hi, i have a value like that var myvalue=myfunction(1,2); what I need is that GETTING myfunction(a,b) as a string.. I mean not "myfunction's value" hmmm, let me explain, myfunction(1,2) returns 1+2=3 if I type alert(myvalue) it returns 3 but I need myfunction(a,b) AS IT'S TYPED when I use alert. NOT IT'S VALUE think it like var myvalue='myfunction(a,b)' now, if i use Alert, it gives me myfunction(a,b) how can I do that?

    Read the article

  • How can I get jquery .val() AFTER keypress event?

    - by werner5471
    I got: $(someTextInputField).keypress(function() { alert($(this).val()); }); Now the alert always returns the value BEFORE the keypress (e.g. the field is empty, I type 'a' and the alert gives me ''. Then I type 'b' and the alert gives me 'a'...). But I want the value AFTER the keypress - how can I do that? Background: I'd like to enable a button as soon as the text field contains at least one character. So I run this test on every keypress event, but using the returned val() the result is always one step behind. Using the change() event is not an option for me because then the button is disabled until you leave the text box. If there's a better way to do that, I'm glad to hear it!

    Read the article

  • how does memory stacks work in javascript

    - by user227353
    When we have code like: function a(){ var x =0; this.add=function(){ alert(x++); } } var test = new a(); test.add(); // alert 0 test.add(); // alert 1 test.add(); // alert 2 How does this work? Doesn't that the value of 'x' in a() should be 'gone' as soon as test = new a() is complete? The stack contains x should also be gone as well, right? Or, does javascript always keep all the stacks ever created in case they will be referenced in future? But that wouldn't be nice, would it...?

    Read the article

  • onPageLoad is not working properly in Firefox Extension Development

    - by Tharaka Deshan
    I am new to Firefox Extension Development and doing my 1st program. Simply I needed to pop up a alert once it loaded the page. My code was like this: var myExtension = { init: function() { if(gBrowser) gBrowser.addEventListener("DOMContentLoaded", this.onPageLoad, false); }, onPageLoad: function(aEvent) { alert("Loaded"); } } window.addEventListener("load", function load(event){ window.removeEventListener("load", load, false); myExtension.init(); },false); But I am getting the alert box for couple of times. Then I found about "#document" and then I added a IF condition: onPageLoad: function(aEvent) { if (aEvent.originalTarget.nodeName == '#document') { alert("Loaded"); } } Unfortunately still I am getting the same. Please advise me on this.

    Read the article

  • YAHOO.util.Connect.asyncRequest does not work in Safari

    - by 24x7Programmer
    When I request a webpage using YAHOO.util.Connect.asyncRequest in Safari I always get Communication Failure message in callback's failure properties statusText. The same method works in IE. What could be wrong here? Here is the code. When the code is executed I always get two alerts: "Three" and "communications failure undefined" (corresponding to the second alert in the failure part below.) Also when I attach the debugger and put break point in the SAProvision.aspx's page load event, the break point is not hit. So it is sure that in safari the page is not being called. While the same is called when executed from IE. function ProvisionBlade() { var path = "http://localhost/SC/Dashboard/SAProvision.aspx" YAHOO.util.Connect.asyncRequest("POST", path, callbacks1, null); } var callbacks1 = { success: function(o) { var check = "test"; alert(o.responseText); }, failure: function(o) { alert("Three"); alert(o.statusText + ' ' + o.responseText); } }

    Read the article

  • .click() callback references local variable from the calling method instead of copying by value

    - by Eric Freese
    The following jQuery Javascript code is included on an otherwise empty page. $(function() { for (var i = 0; i < 10; i++) { element = $('<div>' + i + '</div>'); element.click(function() { alert(i); }); $('body').append(element); } }); The desired behavior is that this code should generate 10 div elements numbered from 0 to 9. When you click on a div element, an alert popup will show the number of the div element you clicked on (i.e. if a user clicks on the div element labeled '4', the alert popup should show the number 4). The alert popup instead shows the number 10 regardless of which div element is clicked on. How can I modify this code to make it behave in the desired way?

    Read the article

  • Problem with handling click event of bitmap

    - by shaina
    i am using navigationClick method to handle click event of Bitmap images & Buttons it works fine when i dont use VerticalFieldManger . But when i adjust positions of field using this field manager then it doesnt capture click event of all controls just on capture Index(0) click which i think is verticalFieldmanager not other (Bitmaps & Buttons fields) Plzzzzzz help how to resolve it code is protected boolean navigationClick(int status, int time) { Field field = this.getFieldWithFocus(); if(field.getIndex()==0) { Dialog.alert("Index 0 (bitmaP) clicked"); } if(field.getIndex()==1) { Dialog.alert("Index 1(Button 1) clicked"); } if(field.getIndex()==2) { Dialog.alert("Index 2 (Button2) Clicked"); } if(field.getIndex()==3) { Dialog.alert("Index 3(bitmap2) Clicked"); } }

    Read the article

  • code in xmlhttp.readyState==4 doen't get executed

    - by shazia
    function download() { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { //alert(xmlhttp.readyState); if(xmlhttp.readyState==4 && xmlhttp.status==200) { alert (xmlhttp.responseText); } } xmlhttp.open("GET","import.php?file="+document.getElementById('uploaded_file').value,false); xmlhttp.send(); // location.reload(true); } if I put alert and monitor xmlhttp.readyState then it shows me that its status does turn 4 and it does go in the if statement, if I don't monitor it with alert then it doesn't go in the if statement but I know import.php is working because I can see the changes in the database. I don't know whats going on...can anyone help. Thanks

    Read the article

  • Does window.open not work inside an AIR html component?

    - by John Isaacks
    I have a component in AIR like so: <mx:HTML id="html" width="100%" height="100%" location="https://example.com" locationChange="dispatchLocationChange(event)" /> The page it loads contains this: <a onclick="alert('onclick')">Alert</a> <a href="javascript:alert('js')">Alert</a> <a onclick="window.open('http://www.google.com','_blank')">new window</a> The 2 alerts both work. however nothing happens when you click the new window link. all 3 links works when in a real browser so I know its ok. Is there just no support for window.open in the AIR HTML component? or is this a bug? Is there a work around?

    Read the article

  • Jquery .$.ajax is not working

    - by Saravanan I M
    I am using $.ajax for facebook invite and calling the url (Yii framework controller). The below code is not working. $.ajax is not working. function FacebookInviteFriends() { FB.ui ( { method : 'apprequests', data: '', display: 'dialog', title : 'Invite a Friend', message: 'I just sent you an invitation to play My Game.', filters: ['app_non_users'] }, function(response) { alert("start"); if (response && response.to) { alert("inside if"); $.ajax({ url: 'http://localhost:83/invitechips/createRecord', type: 'POST', data: {id : response.to} }).done(function() { alert( "Data Saved: "); }); } else { alert("inside else"); } } ); }

    Read the article

  • intialization with a nibFIle failed

    - by zp26
    Hi, I have a problem. I try to initialize a variabile in a classViewController created inside a xib file. I try with the code below but when i append a object to array, these array isn't initialized. Can you help me? thanks and sorry for my english. #import <UIKit/UIKit.h> @interface AccelerometroViewController : UIViewController <UIAccelerometerDelegate, UITextFieldDelegate, UIAlertViewDelegate>{ //..... NSMutableArray *arrayPosizioni; NSMutableArray *arrayPosizioniCorrenti; NSString *nomePosizioneCorrente; } -(IBAction)salvaPosizione; //... @property (nonatomic, assign) NSMutableArray *arrayPosizioni; @property (nonatomic, assign) NSMutableArray *arrayPosizioniCorrenti; @property (nonatomic, assign) NSString *nomePosizioneCorrente; @end #import "AccelerometroViewController.h" #import "Position.h" @implementation AccelerometroViewController float actualX; float actualY; float actualZ; @synthesize arrayPosition; @synthesize arrayCurrentPosition; @synthesize nameCurrentPosition; -(id)init { self = [super init]; if (self != nil) { arrayPosition = [[NSMutableArray alloc]init]; arrayCurrentPosition = [[NSMutableArray alloc]init]; nameCurrentPosition = [NSString stringWithFormat:@"noPosition"]; actualX = 0; actualY = 0; actualZ = 0; } return self; } -(void)updateTextView:(NSString*)nomePosizione { NSString *string = [NSString stringWithFormat:@"%@", nameCurrentPosition]; textEvent.text = [textEvent.text stringByAppendingString:@"\n"]; textEvent.text = [textEvent.text stringByAppendingString:string]; } -(IBAction)savePosition{ Posizione *newPosition; newPosition = [[Position alloc]init]; if([newPosition setValue:(NSString*)fieldNomePosizione.text:(float)actualX:(float)actualY:(float)actualZ]){ //setValue is a method of Position. I'm sure that this method is correct UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Salvataggio Posizione" message:@"Posizione salvata con successo" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; [alert show]; [alert release]; [arrayPosition addObject:newPosition]; } else{ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Salvataggio osizione" message:@"Errore nel salvataggio" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; [alert show]; [alert release]; } } - (void) initialise { arrayPosition = [[NSMutableArray alloc] init]; arrayCurrentPosition = [[NSMutableArray alloc] init]; nameCurrentPosition = @"noPosition"; actualX = 0; actualY = 0; actualZ = 0; } - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle { if (self = [super initWithNibName:nibName bundle:bundle]) { [self initialise]; } }

    Read the article

  • NSString cannot be released

    - by Stanley
    Consider the following method and the caller code block. The method analyses a NSString and extracts a "http://" string which it passes out by reference as an auto release object. Without releasing g_scan_result, the program works as expected. But according to non-arc rules, g_scan_result should be released since a retain has been called against it. My question are : Why g_scan_result cannot be released ? Is there anything wrong the way g_scan_result is handled in the posted coding below ? Is it safe not to release g_scan_result as long as the program runs correctly and the XCode Memory Leak tool does not show leakage ? Which XCode profile tools should I look into to check and under which subtitle ? Hope somebody knowledgeable could help. - (long) analyse_scan_result :(NSString *)scan_result target_url :(NSString **)targ_url { NSLog (@" RES analyse string : %@", scan_result); NSRange range = [scan_result rangeOfString:@"http://" options:NSCaseInsensitiveSearch]; if (range.location == NSNotFound) { *targ_url = @""; NSLog(@"fnd string not found"); return 0; } NSString *sub_string = [scan_result substringFromIndex : range.location]; range = [sub_string rangeOfString : @" "]; if (range.location != NSNotFound) { sub_string = [sub_string substringToIndex : range.location]; } NSLog(@" FND sub_string = %@", sub_string); *targ_url = sub_string; return [*targ_url length]; } The following is the caller code block, also note that g_scan_result has been declared and initialized (on another source file) as : NSString *g_scan_result = nil; Please do send a comment or answer if you have suggestions or find possible errors in code posted here (or above). Xcode memory tools does not seem to show any memory leak. But it may be because I do not know where to look as am new to the memory tools. { long url_leng = [self analyse_scan_result:result target_url:&targ_url]; NSLog(@" TAR target_url = %@", targ_url); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Scanned Result" message:result delegate:g_alert_view_delegate cancelButtonTitle:@"OK" otherButtonTitles:nil]; if (url_leng) { // ****** The 3 commented off statements // ****** cannot be added without causing // ****** a crash after a few scan result // ****** cycles. // ****** NSString *t_url; if (g_system_status.language_code == 0) [alert addButtonWithTitle : @"Open"]; else if (g_system_status.language_code == 1) [alert addButtonWithTitle : @"Abrir"]; else [alert addButtonWithTitle : @"Open"]; // ****** t_url = g_scan_result; g_scan_result = [targ_url retain]; // ****** [t_url release]; } targ_url = nil; [alert show]; [alert release]; [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(activate_qr_scanner:) userInfo:nil repeats:NO ]; return; }

    Read the article

  • Limit text area value and cut the rest

    - by streetparade
    I have a textarea which users can enter some tags. I need to limit this tags to 20 tags. Tags could be enterer this way maytag1,mytag2,mytag3 What i wrote is this function function limitTags() { var tags = $("input[type=text][name=tags]").val() var tag = $.trim(tags); var selected = new Array(); /** * replace the last ',' */ if(tag.substring(tag.length - 1) == ",") { *///tag = tag.replace(tag.length - 1, ''); } var enteredTags = tag.split(","); if( enteredTags.length > 20 ) { //$("input[type=text][name=tags]").val(enteredTags.join(",", enteredTags)); alert("Only 20 Tags allowed"); } } The alert works just fine but, after the alert box is gone. i can continiue entering tags till the alert box appears. What i need is cut the text after the messagebox which was entered also the last "," I hope i could ask my question clear. Thanks

    Read the article

  • Javascript array value is undefined ... how do I test for that

    - by Ankur
    I am trying to test to see whether a Javascript variable is undefined. You will see that I am not expecting the value of predQuery[preId] to be 'undefined' if I don't first get an alert saying "its unbelievable". But I often do, so I am guessing that my statement predQuery[preId]=='undefined') is not matching the undefined elements properly. if((predQuery.length < preId) || (predQuery[preId]=="") || (predQuery[preId]=='undefined')){ alert("its unbelievable"); alert(predQuery[preId]); queryPreds[variables] = preId; queryObjs[variables] = objId; predQuery[preId] = variables; } else { alert(predQuery[preId]); var predIndex = predQuery[preId]; queryPreds[predIndex] = preId; queryObjs[predIndex] = objId; } I can add more code if needed.

    Read the article

  • Concatenating string with number in Javascript

    - by Sparky
    I'm trying to create a simple calculator in Javascript. I have an array named expression chunk[0] = 12 chunk[1] = + (the "+" sign) chunk[1] = 5 I used a for loop to loop through the chunks (chunk[]) and join then into a single expression as follows:- equation = ""; // To make var equation a string for(i = 0; i <= length; i++) { equation = equation + expression[i]; alert(expression[i]); } alert(equation); alert(expression[i]) showed values 12, + and 5. But alert(equation) showed 125 (instead of "12+5"). I need the variable equation to be "12+5" so that I can later call eval(equation) and get the value of 12+5. What am I doing wrong here?

    Read the article

  • Chrome Extension - Console Log not firing

    - by coffeemonitor
    I'm starting to learn to make my own Chrome Extensions, and starting small. At the moment, I'm switching from using the alert() function to console.log() for a cleaner development environment. For some reason, console.log() is not displaying in my chrome console logs. However, the alert() function is working just fine. Can someone review my code below and perhaps tell me why console.log() isn't firing as expected? manifest.json { "manifest_version": 2, "name": "Sandbox", "version": "0.2", "description": "My Chrome Extension Playground", "icons": { "16": "imgs/16x16.png", "24": "imgs/24x24.png", "32": "imgs/32x32.png", "48": "imgs/48x48.png" }, "background": { "scripts": ["js/background.js"] }, "browser_action": { "default_title": "My Fun Sandbox Environment", "default_icon": "imgs/16x16.png" }, "permissions": [ "background", "storage", "tabs", "http://*/*", "https://*/*" ] } js/background.js function click(e) { alert("this alert certainly shows"); console.log("But this does not"); } // Fire a function, when icon is clicked chrome.browserAction.onClicked.addListener(click); As you can see, I kept it very simple. Just the manifest.json and a background.js file with an event listener, if the icon in the toolbar is clicked. As I mentioned, the alert() is popping up nicely, while the console.log() appears to be ignored.

    Read the article

  • JQuery duplicate alerts on update? why?

    - by russp
    I have this JQuery function - that nearly works (so far!) BUT the alerts are duplicated, each appears twice any clues/ideas please $(function() { $("#col1, #col2, #col3").sortable({ connectWith: '.column', update : function () { serial = $('#col1').sortable('serialize'); serial1 = $('#col2').sortable('serialize'); serial2 = $('#col3').sortable('serialize'); alert(serial); alert(serial1); alert(serial2); } }); });

    Read the article

  • Can't access Elements previously created by innerHTML with Javascript/Prototype

    - by Joe Hopfgartner
    I am setting the innerHTML variable of a div with contents from an ajax request: new Ajax.Request('/search/ajax/allakas/?ext_id='+extid, { method:'get', onSuccess: function(transport){ var response = transport.responseText || "no response text"; $('admincovers_content').innerHTML=response; }, onFailure: function(){ alert('Something went wrong...') } }); The response text cotains a form: <form id="akas-admin" method="post" action="/search/ajax/modifyakas/"> <input type="text" name="formfield" value="i am a form field"/> </form> Then I call a functiont that should submit that form: $('akas-admin').request({ onComplete: function(transport){ //alert('Form data saved! '+transport.responseText) $('admincovers_content').innerHTML=transport.responseText; } }); The problem is $('akas-admin) returns null , I tried to put the form with this id in the original document, which works. Question: Can I somehow "revalidate" the dom or access elements that have been inserted with innerHTML? Edit Info: document.getElementById("akas-admin").submit() works just fine, problem is i don't want to reload the whole page but post the form over ajax and get the response text in a callback function. Edit: Based on the answers provided, i replaced my function that does the request with the following observer: Event.observe(document.body, 'click', function(event) { var e = Event.element(event); if ('aka-savelink' == e.identify()) { alert('savelink clicked!'); if (el = e.findElement('#akas-admin')) { alert('found form to submit it has id: '+el.identify()); el.request({ onComplete: function(transport){ alert('Form data saved! '+transport.responseText) $('admincovers_content').innerHTML=transport.responseText; } }); } } }); problem is that i get as far as alert('savelink clicked!'); . findelement doesnt return the form. i tried to place the save link above and under the form. both doesnt work. i also think this approach is a bit clumsy and i am doing it wrong. could anyone point me in the right direction?

    Read the article

  • javascript switch(true)

    - by ntan
    Hi i am trying to handle an ajax json response here is my code success: function (j) { switch(true) { case (j.choice1): alert("choice2"); break; case (j.choice2): alert("choice2"); break; default: alert("default"); break; } } based on what j is return i do my action BUT i keep getting the default. I have alert the j values and come correct.Some how case (j.choice1) case (j.choice2) is not working. I tried case (j.choice1!="") (j.choice2!="") But in this scenario i keep getting the first choice. What am i missing

    Read the article

  • Processing data from an AJAX request

    - by Josh K
    I have a PHP API I'm working with that outputs everything as JSON. I need to call one of the API methods and parse it out using an AJAX request. I am using jQuery (though it shouldn't matter). When I make the request it errors out with a "parsererror" as the textStatus and a "Syntax Error: invalid label" when I make the request. Simplified code: $.ajax ({ type: "POST", url: "http://mydomain.com/api/get/userlist/"+mid, dataType: "json", dataFilter: function(data, type) { /* Here we assume and pray */ users = eval(data); alert(users[1].id); }, success: function(data, textStatus, XMLHttpRequest) { alert(data.length); // Should be an array, yet is undefined. }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert(textStatus); alert(errorThrown); }, complete: function(XMLHttpRequest, textStatus) { alert("Done"); } }); If I leave off the eval(data) then everything works fine. Well, except for data still being undefined in success. Note that I'm taking an array of objects in PHP and then passing them out through json_encode. Would that make any difference? There has been no progress made on this. I'm willing to throw more code up if someone believes they can help. Here is the PHP side of things private function _get_user_colors($id) { $u = new User(); $u->get_where(array('id' => $id)); $bar = array(); $bar['user'] = $u->stored; foreach($user->colors as $color) { $bar['colors'][] = $color; } echo(json_encode($bar)); } I have had zero issues using this with other PHP based scripts. I don't know why Javascript would take issue with it.

    Read the article

  • what is the difference b/w these codes javascript ?

    - by dhaliwaljee
    < input type='text' id='txt' name='txtName' size='20' value='testing'/> <script type="text/javascript" language='javascript'> var val = document.getElementsByName('txtName'); alert(val[0].value); alert(window.txtName.value); </script> In above code we are using alert(val[0].value); alert(window.txtName.value); these two ways for getting value from object. What is the difference b/w both ways and which way is best.

    Read the article

  • JavaScript prototype(ing) question

    - by OneNerd
    Trying to grasp Prototyping in Javascript. Trying to create my own namespace to extend the String object in JavaScript. Here is what I have so far (a snippet): var ns { alert: function() { alert (this); } } String.prototype.$ns = ns; As you can see, I am trying to place what will be a series of functions into the ns namespace. So I can execute a command like this: "hello world".$ns.alert(); But the problem is, the this doesn't seem to reference the text being sent (in this case, "hello world"). What I get is an alert box with the following: [object Object] Not having a full grasp of the object-oriented nature of JavaScript, I am at a loss, but I am guessing I am missing something simple. Does anyone know how to achieve this? Thanks -

    Read the article

  • render json data returned from mvc controller

    - by user1765862
    I'm having js function which calls mvc controller action method which return list of data as json. function FillCountryCities(countryId) { $.ajax({ type: 'GET', url: '/User/FillCityCombo', data: { countryId: countryId }, contentType: 'application/json', success: function (data) { alert(data[0].Name); } error: function () { alert('something bad happened'); } .... format of data which sent back from controller is Name (string) and Id (Guid) Now I just want to alert Name on success first item from collection. Double checked controller sends 20 records, so it should alert first from collection but I'm getting error something bad happened update: public JsonResult FillCityCombo(Guid countryId) { var cities = repository.GetData() .Where(x = x.Country.Id == countryId).ToList(); if (Request.IsAjaxRequest()) { return new JsonResult { Data = cities, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } else { return new JsonResult { Data = "Not Valid Request", JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } }

    Read the article

  • How to tell if JSON object is empty in jQuery

    - by GrantU
    I have the following JSON: { "meta": { "limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 0 }, "objects": [] } I'm interested in objects: I want to know if objects is empty and show an alert: something like this: success: function (data) { $.each(data.objects, function () { if data.objects == None alert(0) else :alert(1) });

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >