Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php脚本中的jquery检查会话,然后将单击的项目保存到mysql数据库,并更新已单击的标签_Php_Jquery - Fatal编程技术网

使用php脚本中的jquery检查会话,然后将单击的项目保存到mysql数据库,并更新已单击的标签

使用php脚本中的jquery检查会话,然后将单击的项目保存到mysql数据库,并更新已单击的标签,php,jquery,Php,Jquery,嗨,我正在尝试保存以将项目保存到我的sql数据库中我有3个函数 /* the function below checks if a session is pressent using jquery ajax call to php script */ function checkSess(){ $.ajax({ url: "check_s.php",

嗨,我正在尝试保存以将项目保存到我的sql数据库中我有3个函数

/* the function below checks if a session is pressent using jquery ajax call to php script */


function checkSess(){
                         $.ajax({
                         url: "check_s.php",
                         cache: false,
                         success: function(data){
                                                processDetails1(data)
                                                }
                                 });
                     }


<?php
session_start(); 
if(isset($_SESSION['flipmode']))
{ 

    echo "u";
}
 else {
    echo "n";
}

?>


/* the function below checks if value from checkSess() is true or false */


function processDetails1(info){

              if(info==='u'){

                  return true;
              }
               else{
                    return false;
                }
           }





/* the function below checks if value from checks all data then saves to database and changes label if the result from processDetails1 and if true is returned then changes label details and if it returns false should open dialog*/


$('.savepropertycon').live('click', function() {
                var chekH = checkSess();
                if(chekH===true){
                     $.get("saveprop.php", { pid: saveId },
                            function(data){
                    $('#dialog-message').dialog('open');
                                $('#pro').html(data);
                                return false; 
                                        });


                var saveCurrentId = $(this).attr('id');

                    jQuery("label", this).html('saved');
                    $(this).removeClass();
                    $(this).removeAttr('href');
                    $(this).addClass("savedone");
                    jQuery("img", this).remove();


                }
                else {

                    $('.dialogsign').dialog('open');

                }




                return false;
            });
/*下面的函数使用jquery ajax调用php脚本检查会话是否存在*/
函数checkSess(){
$.ajax({
url:“check_.php”,
cache:false,
成功:功能(数据){
processDetails1(数据)
}
});
}
/*下面的函数检查checkSess()中的值是true还是false*/
函数processDetails1(信息){
如果(信息=='u'){
返回true;
}
否则{
返回false;
}
}
/*下面的函数检查值是否来自检查所有数据,然后保存到数据库并更改标签如果processDetails1的结果返回true,则更改标签详细信息,如果返回false,则应打开对话框*/
$('.savepropertycon').live('单击',函数()){
var chekH=checkSess();
如果(chekH==真){
$.get(“saveprop.php”,{pid:saveId},
功能(数据){
$('#对话框消息')。对话框('打开');
$('#pro').html(数据);
返回false;
});
var saveCurrentId=$(this.attr('id');
jQuery(“label”,this.html('saved');
$(this.removeClass();
$(this.removeAttr('href');
$(this.addClass(“savedone”);
jQuery(“img”,this).remove();
}
否则{
$('.dialogsign').dialog('open');
}
返回false;
});

我遇到的问题是,上面的代码保持并返回false,我尝试用firebug进行调试,var chekH返回为未定义。请有人帮忙谢谢。

所以如果你想保存一个标签,我推荐一个jquery插件。它将为您完成大部分工作。因此,您的javascript将如下所示:

 $(document).ready(function() {
     $('.edit').editable('http://www.example.com/save.php', {
       type: edit
     });
 });
<span class="edit" id="tableid">Text</span><br />
<span class="edit" id="anothertableid">Some Text</span>
您的html应该如下所示:

 $(document).ready(function() {
     $('.edit').editable('http://www.example.com/save.php', {
       type: edit
     });
 });
<span class="edit" id="tableid">Text</span><br />
<span class="edit" id="anothertableid">Some Text</span>
Text
一些文本
您的php看起来像: save.php


所以如果你想保存一个标签,我建议你使用jquery插件。它将为您完成大部分工作。因此,您的javascript将如下所示:

 $(document).ready(function() {
     $('.edit').editable('http://www.example.com/save.php', {
       type: edit
     });
 });
<span class="edit" id="tableid">Text</span><br />
<span class="edit" id="anothertableid">Some Text</span>
您的html应该如下所示:

 $(document).ready(function() {
     $('.edit').editable('http://www.example.com/save.php', {
       type: edit
     });
 });
<span class="edit" id="tableid">Text</span><br />
<span class="edit" id="anothertableid">Some Text</span>
Text
一些文本
您的php看起来像: save.php


您应该在帖子中清理您的代码示例。。太多的空格,很难浏览。所以太多的空格你应该在帖子中清理你的代码示例。。太多的空间,很难浏览。太多的空白,谢谢你编辑我的文章。我不想保存标签我想做的是将列表中某个iteam的详细信息保存到数据库中。在成功的iteam被保存到数据库的链接按钮被更改为保存。首先,感谢编辑我的文章。我不想保存标签我想做的是将列表中某个iteam的详细信息保存到数据库中。成功将iteam保存到数据库后,链接按钮将更改为保存。