0

I have this message when I using ajax with Google Chrome

event.returnValue is deprecated. Please use the standard event.preventDefault() instead

I installed new G.Chrome and new jquery library, but it's not giving effect. And my code works well in Mozilla Firefox. I have file with jQuery code edit.php and action file editting.php.

Code of edit.php:

 $('#submit').click(function(){  
      //if( this.value == "apl" )  
       var id = $("#inf_id").val();
       var text = $("#text").val();
       var title = $("#title").val();
      $("#imgLoad").show(); // Показываем прелоадер
      
      //setTimeout('$("#imgLoad").show()', 1000);
         $.ajax({  
                url: "editting.php",  
                type: "POST",
                data: {"inf_id": id,"title": title,"text":text},
                cache: false,  
               success: function(response){ 
               //////////////////////////// 
    alert(response);               
               //////////////////////////////
            if(response == 0){ // Смотрим ответ от сервера и выполняем соответствующее действие
                //alert("Больше нет записей");  
                $("#imgLoad").hide();
                $("#success_div").show();
                $("#alert_div").hide(); 
                $("#empty_infs_div").hide();                    
                setTimeout('$("#success_div").hide();', 2000);  
                
                $("#empty_text").hide();
                $("#empty_title").hide();                                   
            }else if(response == 1){
                $("#imgLoad").hide();
                $("#success_div").hide();
                $("#alert_div").show(); 
                $("#empty_infs_div").hide();
                setTimeout('$("#alert_div").hide();', 2000);    
                
                $("#empty_text").hide();
                $("#empty_title").hide();
            } /*else if(response == 2){
                $("#imgLoad").hide();
                $("#success_div").hide();
                $("#empty_infs_div").show();
                $("#alert_div").hide();                         
                setTimeout('$("#empty_infs_div").hide();', 2000);
            }*/
            
            else if(response == 2 || response == '2'){
                $("#empty_text").hide();
                $("#empty_title").show();
                
                $("#imgLoad").hide();
                $("#success_div").hide();
                $("#empty_infs_div").hide();
                $("#alert_div").hide(); 
                setTimeout('$("#empty_title").hide();', 2000);
                }
            else if(response == 3){ //if(response == 4)     
                $("#empty_text").show();
                $("#empty_title").hide();
                
                $("#imgLoad").hide();
                $("#success_div").hide();
                $("#empty_infs_div").hide();
                $("#alert_div").hide(); 
                setTimeout('$("#empty_text").hide();', 2000);
                }
            
            }//success  
            }); 
               
        });  

and editting.php:

                <?
            include("site_blocks/bd.php");
            if (isset($_REQUEST['inf_id'])) {$id = $_REQUEST['inf_id']; 
            if ($id == '') {unset($id);}}
            
            if (isset($_REQUEST['title'])){$title = $_REQUEST['title']; 
            if ($title == '') {unset($title);}}
            
            if (isset($_REQUEST['text']))  {$text = $_REQUEST['text']; 
            if ($text == '' || $text == '<br>' ) {unset($text);}}
            
            if (isset($title) && isset($text))
            {
                mysql_query('SET NAMES utf8');ob_clean();
                $update_infs = mysql_query ("UPDATE data SET title='$title',text='$text' WHERE id='$id'");      
            
                if($update_infs==1) {sleep(1); echo 0;}
                else {sleep(1); echo 1; }
            }
            
            else 
            {sleep(1);
            if (!isset($title)) {echo 2;}
            else if(!isset($text)) {echo 3;}
            }
            
            ?>

Alert is works, shows me results 0,1,2,3. But browser Chrome isn't reacting to this numbers. Mozilla reacts as well as I expected.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • This is not an error, it's a warning. It's being generated by jQuery, you can ignore it. It is not affecting your code. To make it go away, update jquery. – Kevin B Mar 18 '14 at 19:24
  • I suggest that you debug the code in Chrome console and execute step by step, checking if the variables have the values you are expecting. – George Marques Mar 18 '14 at 19:31

1 Answers1

1

event.returnValue is deprecated. Please use the standard event.preventDefault()

is just a warning (see here), it should work in chrome and firefox! if its not working in chrome you should check your code: for example:

setTimeout('$("#success_div").hide();', 2000); 

should be changed to

setTimeout($("#success_div").hide(), 2000); 

the first parameter of setTimeout() should be a function (see here), not a string

[edit] corrected the semicolon leftover

i checked your js-code with jslint and there are 2 main errors, the one above with setTimeout "Implied eval is evil. Pass a function instead of a string." and one error with your conditions

Expected '===' and instead saw '=='.
line 32 character 33:    } else if (response == 1) {

but this one shouldnt make the code not working

Community
  • 1
  • 1
Soraphis
  • 706
  • 7
  • 26