Multiple data in .ajax() function
#1

Hi guys
I'm making my UCP and I got stuck when I want to send multiple data using .ajax function, here is the code!

this is how I tried:

Code:
else
	{
		var area_str = "edit_ban_textarea=" + value;
		var id_val = "edit_ban_id=" + id;
		$.ajax({
			type: 'POST',
			url: 'edit_ban.php',
			data: "edit_ban_textarea=" + $.toJSON(value) + "&edit_ban_id=" + $.toJSON(id),
			success: function(response) {
				$('#edit_ban_error_report').css({'border':'1px solid #098fc7', 'padding':'5px 5px 5px 5px', 'width': '81.6%', 'background':'#94ddfb', 'color':'white'}).html('<center>'+response+'</center>');
				setTimeout('FadeOutBanEdit(\''+element_remove_textarea+'\', \''+response+'\')', 3000);
			}
		});
	}
Reply
#2

Use a callback to send the data.

Code:
var dOut = {
 init: function (...){
  //... Initialzie your ajax configuration here
 },
 $.ajax(){
  //.. your code here
 }
}
The best thing you can do is use console.log() to debug your code.
Reply
#3

can you show code with example values and variables? Thanks!

fixed man! solution:

HTML Code:
var datastr = "edit_ban_textarea=" + value + "&edit_ban_id=" + id;
		$.ajax({
			type: 'POST',
			url: 'edit_ban.php',
			data: datastr,
			success: function(response) {
				$('#edit_ban_error_report').css({'border':'1px solid #098fc7', 'padding':'5px 5px 5px 5px', 'width': '81.6%', 'background':'#94ddfb', 'color':'white'}).html('<center>'+response+'</center>');
				setTimeout('FadeOutBanEdit(\''+element_remove_textarea+'\', \''+response+'\')', 3000);
			}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)