Here is the code

$(document).ready(function(){ $('#writesform').submit(function() { $.ajax({ url: "../register/writes/wall_support.php", type: "POST", dataType: "text", data: {write: $('#textarea').val(), button: $('#sub').val()}, success: function(data) { var arr = data.split('^'); var app = '<form><div>'arr[0]'Опубликовал 'arr[1]' администратор 'arr[2]'<button onclick="return delpost();" type="submit" name="number" value="'arr[3]'">удалить</button></div></form>'; $('.wall').append(app); } }) return false; }); }); 

Ajax does not work in this case, but if arr[0] , arr[1] , arr[2] , arr[3] removed from the append , everything works. What is the problem?

  • four
    so what are you doing? '<form> <div>' + arr [0] + 'Posted' + arr [1] + '... - Specter

1 answer 1

I see the problem as a minimum in the fact that string concatenation in js occurs through the operator "+". Still it is impossible to transfer lines in string literals.

I really love this approach: String.Format in JavaScript .

PS I apologize for repeating @Spectre .

  • I'm not special, but there seems to be a point for this. - jonyrock pm