Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 6 years ago

#2239 closed bug (worksforme)

plus sign (+) in data: element of ajax not sent to server

Reported by: dasacc22 Owned by:
Priority: minor Milestone: 1.2.3
Component: ajax Version: 1.2.2
Keywords: + plus Cc:
Blocked by: Blocking:

Description

I have tried escape()'ing the plus sign and i have tried sending it just as is, but the server does not get it, below i do both by appending my escaped form data to "my+content", again, server does not receive any plus signs.

<script>
function submitform() {
	article = $("#article").val();
	header = escape($("#header").val());
	content = escape($("#content").val());
	alert(content);
	$.ajax({
		type: "POST",
		url: "article_save.php",
		data: "article="+article+"&header="+header+"&content=my+content"+content,
		success: function(html) {
			$("#debug").html(html);
		}
	});
}
</script>

Change History (2)

comment:1 Changed 12 years ago by davidserduke

Resolution: worksforme
Status: newclosed

The problem is for an encoded URI the plus sign means spacebar. escape() has been deprecated in javascript. It should work using encodeURIComponent() instead. Or you can let jQuery do it for you by passing in an object with your data like

$.ajax({
  type: "POST",
  url: "article_save.php",
  data: {
    article : $("#article").val(),
    header : $("#header").val(),
    content : $("#content").val()
  },
  success: function(html) {
    $("#debug").html(html);
  }
});

That should also work (assuming I didn't make any typos or mental errors).

Try those out and if you still find there is a bug you can reopen the ticket. Hope that helps.

comment:2 Changed 6 years ago by hovog@…

$( "#cackulatr input" ).on('change',function() {

var z = $("#nambr1").val();

var h = $("#nambr2").val(); var w = $("#nambr3").val(); var k = z + h ; alert(k)

Note: See TracTickets for help on using tickets.