form isset不适用于jquery

时间:2012-10-02 09:10:01

标签: sql forms submit isset

您好我正在使用图像浏览器,我在其中有一个提交按钮,用于向数据库添加新行。不幸的是,isset功能不起作用。当我删除这个if语句时它工作正常,但是当使用if(isset($ _ POST ['addImg']))时没有任何反应。

图片浏览器的格式为:

<div id="galleryAdd">
    <form enctype="multipart/form-data" method="post" >     
        <!-- een hidden id meegeven voor de plaatsing -->
        <input type="hidden" name="parentID" value="<? //$_GET['b']?>40">
        <input type="submit" name="addImg" value="Toevoegen" />
    </form> 
</div>
<div id="addExisting"></div>

点击图片项时,javascript正在调用页面加载:

$('.imgItem').click(function() {
        $('.imgItem').removeClass("image_select");
        $(this).addClass("image_select");   
        var imgsource = $(this).find('img').attr('src'),
            folderID = $(this).find('img').attr('rel');
        $("#addExisting").load("ajax.addExisting.php", {parentID:folderID, imgsource:imgsource});
        return false;   
    });

ajax.existing.php:点击图片时加载的页面

/* Algemene Gegevens bestand */
$bestand = $_POST['imgsource'];

/* Meta Gegevens bestand */
$file = substr($bestand, 0,strrpos($bestand,'.'));
$ext = substr(strrchr($bestand,'.'),1);
$base = basename($file);


if(isset($_POST['addImg'])){
/* Parent */
$queryParent = mysql_query("SELECT * FROM `image_folders` WHERE id = ".$_POST['parentID'].""); 
$parent = mysql_fetch_assoc($queryParent);
$bestand_folder = "../../images/".$parent['dirname']."/";


mysql_query("INSERT INTO images (positie, parent, parentID, naam, alt, titel, extensie) VALUES ('99', '".$parent['name']."', '".$parent['id']."', '".$base."', '".$base."',     '".$base."','".$ext."')")or die('kan niet uploaden'.mysql_error());

  }

2 个答案:

答案 0 :(得分:1)

但您没有发布addImg

您只发送了{parentID:folderID, imgsource:imgsource}

的ajax页面

变化

$("#addExisting").load("ajax.addExisting.php", {
                              parentID:folderID, 
                              imgsource:imgsource});

$("#addExisting").load("ajax.addExisting.php", {
                              parentID:folderID, 
                              imgsource:imgsource,  
                              addImg:'Toevoegen'});

答案 1 :(得分:0)

您未在addImg来电中发送.load()字段。您发送的唯一字段是parentIDimgsource。如果您需要addImg,请将其添加到.load()

的参数中