Reputation: 8385
I have a question re the ajax data - Do I need to set a variable to each value I want to pass? - in this case it will be the value that has been inputted into the input box. Also were abouts can I output console.log(data)
to see whats in the ajax data array?
Function:
function urlCheck() {
$(".postForm").on('click', '#post_title', function (e) {
var id = $('#post_title').data("id");
e.preventDefault();
$.ajax({
url: '<?=base_url()?>/page/op',
data: {
post_title: $("#post_title").val(),
'website_id': id
},
type: 'POST',
success: function (resp) {
alert(resp);
},
error: function (resp) {
console.log("Error in ajax request");
}
});
});
}
Upvotes: 0
Views: 39
Reputation: 18786
To see the data array create it first:
var data = {
param1 : "foo",
param2 : "bar"
};
console.log(data);
The use it in your ajax call
$.ajax({
//...
data:data
//...
});
If you don't add a variable then it isn't passed so if you have to have it, just set it to an empty string.
Upvotes: 3