I have a ajax function that is passing a string of variables to my script but I have one variable that needs to contain a full url with parameters.
What happens is t
Don't try to build your form data by hand. jQuery will encode it for you (with appropriate escaping) if you pass it an object.
var url = "http://domain.com/index.php?var1=blah&var2=blah";
$.ajax({
type: "POST",
url: "/scripts/error_check.php",
data: { url: url, rooftop_id: rooftop_id },
dataType: 'json'
});
Use encodeURIComponent() on url variable:
var url = "http://domain.com/index.php?var1=blah&var2=blah";
var dataArray = "rooftop_id=1&url=" +encodeURIComponent(url);
$.ajax({
type: "POST",
url: "/scripts/error_check.php",
data: dataArray,
dataType: 'json'
});