javascript

jQuery.ajax success callback function not executed

I have a JavaScript Ajax call (jQuery.ajax), that does not execute the success callback function. $.ajax({ url: target, contentType: 'application/json; charset=utf-8', type: 'POST', // type: 'GET', dataType: 'jsonp', error: function (xhr, status) { alert(status); }, ...

How can a Javascript object refer to values in itself?

Hi, Lets say I have the following javascript: var obj = { key1 : "it ", key2 : key1 + " works!" }; alert(obj.key2); This errors with "key1 is not defined". I have tried this.key1 this[key1] obj.key1 obj[key1] this["key1"] obj["key1"] and they never seem to be defined. How can I get key2 to refer to key1's value? ...

Remove leading whitespaces using variable length lookbehind in RegExp

Hello, I'm wondering if variable length lookbehind assertions are supported in JavaScript's RegExp engine? For example, I'm trying to match the string "variable length" in the string "[a lot of whitespaces and/or tabs]variable length lookbehind", and I have something like this but it does not go well in various RegExp testers: ^(?<=[ ...

popup with dynamic menuitems, each menuitem is another popup

I am building an extension that has a pop up whose elements are constructed by a function call everytime the mouse hovers over the popup option. I am able to achieve this. Now I need to have a popup for each of the menu item (inside the original popup) which is not dynamic though. I have this code, but it does not work: for (var m=0; m ...

Get html from clipboard in javascript

I need to implement task which is quite common feature for RichTextEditors - take HTML from clipboard. Can anyone help with guide on how to solve this task? It has to be cross platform (IE, FF, Chrome, Opera). I just started from this code: <script type="text/javascript"> $('.historyText').live('input paste', function(e) { ...

How do I handle the messages for a simple web-based live chat, on the server side?

I'm building a simple live chat into a web application running on Django, but one thing I'm confused about is how I should store the messages between users. The chat will support multiple users, and a chat "session" is composed of users connected to one user that is the "host." The application is a sort of online document collaboration...

How to reload page every 5 second?

Hi I am converting one layout to html , once I make the changes in code html/css then every time I have to hit F5. is there any simple javascript/ jQuery solution for this. like i add the script and its reload the whole page every 5(or specific time) thanks ...

Appending a string to a tinyMCE instance

Hi, I need to append a string (an img tag) to a tinyMCE editor instance. I was doing it like this: $("#textboxhiddenbytinymce").append( string ); tinyMCE.triggerSave(); with no luck. I was wondering if: There is a direct method for adding an arbitrary string (I need complete control over it) to an instance of tinyMCE I understand th...

Guaranteeing the onmouseout event to fire

Hello everybody, I'm currently developing a web application and have run into a little problem. I'm using ExtJS, but I believe this to be a general JS question. When the cursor enters an HTML element, the onmouseover event is fired, when the cursor leaves that element, onmouseout is triggered. So far, so good. Unfortunately, it seems o...

CSS/JS: Evenly spreading elements across multiple lines

How would you go about evenly spreading elements across multiple lines, for example: wrapper div: <div style="text-align: center"> elements inside: <div style="display: inline-block; padding-left: 10px; padding-right: 10px;">Element</div> Instead of only having one element on the next line (wrapped): Element 1 ...

Textarea value="Value" not working onload, but will onblur.

Here is my jsfiddle example, the textarea shows no value onload, but will onblur, does textarea not accept the value attribute? ...

jQuery find not working

This is my HTML: <p class="first">blah blah <a href="" class="more">read more</a></p> <div class="read_more"> <p>more text</p> </div> And javascript: $(document).ready(function(){ $('a.more').click(function(){ $(this).find('.read_more').slideDown(); return false; }); }); Doesn't seem ...

PHP/Javascript - get php variable within javascript

I have run into an interesting problem. I am currently developing php page and need to access a php variable within the javascript onload. $(document).ready(function() { var temp = <?php $page_id ?> } is this valid? I know that this might seem weird and not be allowed but I am developing a page that has two popup windows. The wi...

Move <option> to top of list with Javascript

I'm trying to create a button that will move the currently selected OPTION in a SELECT MULTIPLE list to the top of that list. I currently have OptionTransfer.js implemented, which is allowing me to move items up and down the list. I want to add a new function function moveOptionTop(obj){ var i = obj.selectedIndex; if(i == 0){return;...

How to add a class to the immediate children of an <li>?

<ul> <li><a href="">link 1</a></li> <li><a href="">link 2</a></li> <li><a href="">link 3</a> <ul> <li><a href="">link 1</a></li> <li><a href="">link 2</a></li> </ul> </li> </ul> How to add class to the immediate children 'a' of the LI, while on hover of the LI. while i mouse out of the LI. the class should be removed...

How to show a server side error message in a popup using php

Hi all, I found some of the similar questions here but they are all in C#. So kindly tell me the easiest way to show the server side error message using popup. The popup may be anything like thickbox, modalpopup etc... Here is the sample code. I didn't get the error message in the popup. <script type="text/javascript" src="thickbox...

ASP.NET How to redirect to another web site from a page inside a frame

Hi folks: I get one page inside frame which intends to redirect users to another web site. However, only the the page inside the frame get changed to another web site. What kind of measure can I use to redirect whole doucment to another web site? Thank you! ...

turn javascript local variable into global variable

I have a javascript function to generate a var. That function is activated by an onclick button event. After that var is generated, I need to use it as a global var so that other js processes can use that var. How do I do it? ...

Is there a way to use javascript to check if a button has been clicked

Hi all, I'm just curious if there is a simple way to do this, something along these lines javascript: if(document.getElementById('button').clicked == true) { alert("button was clicked"); } html: <input id="button" type="submit" name="button" value="enter"/> Thank You Ruth ...

Getting the dynamic value of a checkbox in repeating region loop with Jquery

How do I get the values of a check box that is in a repeating region with its values dynamically generated from a recordset from the database.I want to retrieve the value when it is checked and after I click on a link.The problem is that it is retrieving only the first value of the recordset which is 1.This is the code: jQuery: $(docum...