jquery - Weird javascript problem -
I am creating a page that loads intensively with AJAX.
This is what '$' is. Get '
jQuery function calls (located on the external HTML page):
& lt; Script type = "text / javascript" & gt; $ (Function () {$ ('button') sb_animateButton (); .. $ ('input') sb_animateInput (); $ ('# settings_security_error') to hide (;);}); Function check_password (password, password_upconfig) {$ ('# settings_security_error'). Show (); Warning ('I am in funcion!'); // This works ... if (password.length & lt; 4) // ... this is not {$ ('# settings_security_error'). InnerHTML = 'Password too small'; } Else {password = hex_md5 (password); Password_confirm = hex_md5 (password_confirm); $ Get ('? / Engine / ajax / check_password.php password =' + password + '$ password_confirm =' + password_confirm, {language: "php", version: 5}, function (result) {$ ('# settings_security_error '). WinnerHTML = result;},' html '); }} & Lt; / Script & gt; & Lt; Div class = "title" & gt; Security & lt; / Div & gt; & Lt; Table class = "sub-container" & gt; & Lt; TR & gt; & Lt; Td> & Lt; Label & gt; Old password & lt; / Label & gt; & Lt; / Td> & Lt; Td square = "td_input" & gt; & Lt; Input type = "password" name = "old_password" /> & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td> & Lt; Label & gt; New password & lt; / Labels & gt; & Lt; / Td> & Lt; Td class = "td_input" & gt; & Lt; Input type = "password" name = "new_password" id = "settings_security_new_password" onkeyup = "check_passwords (this.value, getElementById ('settings_security_password_confirm') value.)" / & Gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td> & Lt; Label & gt; Confirm Password & lt; / Label & gt; & Lt; / Td> & Lt; Td class = "td_input" & gt; & Lt; Input type = "password" name = "new_password_confirm" id = "settings_security_password_confirm" onkeyup = "check_passwords (.getElementById ('settings_security_new_password') value, this.value)" /> & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td class = "td_error" id = "settings_security_error" & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt;
And this is where external HTML is placed ...:
... From this JavaScript snippet:
the function get_page_content (page, target_id) {$ .Get ('engine / ajax / get_page_content.php? Page = '+ Page, blank, function (result) {$ ("#" + target_ID) .html (result); // or whatever you want to insert the result},' html '); }
Good ... The problem is that javascript is executed in the first snippet when it $ Get loaded by the function, but I still understand the reason that when I do nothing in the input box, td class = "td_error" id = "settings_security_error" & gt;; & Lt; This Javascript function should be typed in the
check_passwords (password, password_confirm)
& lt / td & gt;
.
Thanks for the help.
'). InnerHTML = 'Password too small';
$ ('# settings_security_error')
is a jQuery object; Not a DOM element you are meaninglessly setting innerHTML
property on a jQuery object; Whatever
want to set the DOM elements innerHTML
can be done directly:
$ ('# settings_security_error') [0] .innerHTML = 'Password too short'; Receive
or
$ ('# settings_security_error') (0) .innerHTML = 'Password too short';
Or you can use jQuery or work (text is being sharpened):.
$ ('# settings_security_error') text ('password too small');
or
$ ('# settings_security_error'). Html ('password too small');
Comments
Post a Comment