2013-06-13 79 views
0

我對$ .ajax有個大問題。我嘗試將文件名發送到PHP部分(在同一個文件中),以幫助我在$ _SESSION中存儲該名稱。 它昨天工作完美,但不再了。是否存在瀏覽器問題而不是代碼問題? 這裏是我的代碼:

JS功能

<script type="text/javascript" charset="utf-8"> 

function no_select(){ 
    var images = $("#selected_images").text(); 
    if(images != ''){ 
     var tmpFile = $("#selected_images").text(); 
     var arrayFile = tmpFile.split(","); 
     if (arrayFile.length > 2){ 
      alert("Il ne faut selectionner qu'un seul badge !"); 
      return false; 
     } 
     var value = $.ajax({ 
      type: "GET", 
      dataType: "json", 
      url: "overview_list.php", 
      data: "selectedImage="+arrayFile[0], 
      async: false, 
      success: function() 
      { 
      return true; 
      } 
     }); 

     return true; 
    } else if(images == ''){ 
     alert("Il faut selectionner un badge"); 
     return false; 
    }  
} 

</script> 

PHP

<?php 
if(!empty($_GET['selectedImage'])){ 
    $let = $_GET['selectedImage']; 
} else { 
    $let = ""; 
} 

$_SESSION['selectedImage'] = $let; 
?> 

我已經查了很多各地的網絡解決方案,但對我來說是無解。

+0

'在session_start()'請。 – moonwave99

+0

這是問題......我不知道如何,但行被壓制。非常感謝 – Gezurb

回答

0

應該是這樣

$.ajax({ 
        type: "GET", 
        dataType: "json", 
        url: "overview_list.php", 
        data: {selectedImage:arrayFile[0]}, 
        async: false, 
        success: function() 
        { 
        return true; 
        } 

和makesure arrayFile [0]是越來越值

+0

Oups對不起,我之前有POST,我改變了它的測試...並且我的arrayFile [0]具有正確的值,我在發送之前解析它。我有另一個功能,它做了相同的工作,但我會盡力謝謝你 – Gezurb