2014-09-06 28 views
1

我有一個圖像呈現設施上的按鈕單擊顯示圖像上的輸出div的唯一第一一個但不顯示相同的另一次點擊更改我正在做圖像模因的代碼,以便我可以在圖像上寫文字並給出一些效果。它只是第一次顯示圖像,就像我上面所說的點擊我序列化表單數據。之後,我通過jQuery ajax調用傳遞給ajaxfunctions頁面。當我點擊按鈕它顯示圖像與jQuery ajax輸出div'mouse_move'只爲第一個,但不顯示相同的另一個點擊

var data = { 
    'field_name': 'formdata', 
    'outer_offset_left': offset.left, 
    'outer_offset_top': offset.top, 
    'drag_offset_left': dragOffset.left, 
    'drag_offset_top': dragOffset.top, 
    'drag_offset_left2': dragOffset2.left, 
    'drag_offset_top2': dragOffset2.top, 
    'outer_width': outerWidth, 
    'outer_height': outerHeight, 
    'drag_width': dragWidth, 
    'drag_height': dragHeight, 
    'drag_width2': dragWidth2, 
    'drag_height2': dragHeight2, 
    'fontsize': font_size, 
    'fontsize2': font_size2, 
    'file_name_path': file_path, 
    'file_background_url': outer_bg_url, 
    'file_background_color': outer_bg_color, 
    'drag_text': drag_text, 
    'drag_text2': drag_text2, 
    'font_type': font_type, 
    'font_type2': font_type2, 
    'shadow_val': shadow_val, 
    'cap_val': cap_val 
}; 

data = $('#my-form').serialize() + "&" + $.param(data); 

$.ajax({ 
    type: "POST", 
    dataType: "html", 
    url: "source/ajax-functions.php", 
    //Relative or absolute path to response.php file  
    data: data, 
    success: function (data) { 
     setTimeout(function() { 
      $("#mouse_move").css({ 
       'display': 'block' 
      }).html(data); 
     }, 200);   
    }  
}); 

on ajax-functions.php我只是在更新後回顯圖像,但它會顯示它第一次生成的輸出。

echo '<img src="'.$pathToImage.'custom_Text_image.jpg" />'; 

但內部的每件事情都很好。圖像已成功更新,因爲我想要。

回答

1

這條線:

data = $('#my-form').serialize() + "&" + $.param(data); 

將第二時間添加當前形式data每次運行。它只會正常運行一次。

假定,data="abc"

// 1 
data = $('#my-form').serialize() + "&" + $.param(data); 
// <formadata>&abc 

// 2 
data = $('#my-form').serialize() + "&" + $.param(data); 
// <formadata>&abc<formdata>&abc 

// etc. 

變化:

datatosend = $('#my-form').serialize() + "&" + $.param(data); 

$.ajax({ 
        type: "POST",  
        dataType: "html",  
        url: "source/ajax-functions.php", 
        //Relative or absolute path to response.php file  
        data: datatosend,  
        success: function(
... 
相關問題