SA-MP Forums Archive
Multiple data in .ajax() function - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Other (https://sampforum.blast.hk/forumdisplay.php?fid=7)
+--- Forum: Everything and Nothing (https://sampforum.blast.hk/forumdisplay.php?fid=23)
+--- Thread: Multiple data in .ajax() function (/showthread.php?tid=327055)



Multiple data in .ajax() function - System64 - 19.03.2012

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);
			}
		});
	}



Re: Multiple data in .ajax() function - XFlawless - 20.03.2012

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.


Re: Multiple data in .ajax() function - System64 - 20.03.2012

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);
			}