Reputation: 299
I am trying to concatenate two var values and then place them in an ajax post URL but I keep getting error reports.
I will show you what I have tried to do:
var photoId = 227;
var jobId = 334;
$.ajax({
type: "POST",
url: "<?= $this->baseUrl() ?>/modelling/jobs/remove-photo/'j=' +jobId + '&p=' + photoId + "
The above produced the below values
http://127.0.0.1/website/modelling/jobs/remov...j=%27%20+jobId%20+%20%27& p=%27%20+%20photoId%20
I would be very grateful if someone could please tell me where I have gone wrong with the concatenation.
Upvotes: 0
Views: 85
Reputation: 6275
Looks like the single and double quotes are mixed together. Did you mean this for your url variable?
url: "<?= $this->baseUrl() ?>/modelling/jobs/remove-photo/?j=" + jobId + "&p=" + photoId
Upvotes: 0
Reputation: 10603
Seem's you're using single quotes to drop out of the string, but you start the string with double quotes? you also have a single quote where i believe you should have a question mark...
change it too:
url: "<?= $this->baseUrl() ?>/modelling/jobs/remove-photo/?j=" +jobId + "&p=" + photoId + ""
Upvotes: 1