Why isn't this data being sent to my controller? No sign of jsonForm in firebug. No success alert.
JS
$('form').submit(function() {
var title = $('#title:input').val();
alert(title);
var urlsStr = $("#links").val();
var urls = urlsStr.match(/\bhttps?:\/\/[^\s]+/gi);
var formData = {
"title": title,
"urls": urls
}
var jsonForm = JSON.stringify(formData);
$.ajax({
type: 'GET',
dataType: 'json',
cache: false,
data: { jsonForm: jsonForm },
url: 'publishlinks/publish',
success:
function(response) {
alert('winrar');
}
})
})
Controller
function publish() {
$form = $this->input->get('jsonForm');
echo json_decode($form);
$data = array(
'movieid' => $this->input->post('id')
);
$this->load->model('publish_model');
$this->publish_model->add_record($data);
$this->load->model('NewsFeed_model');
$feed['queryMovies'] = $this->NewsFeed_model->getPublications();
$this->load->view('news_feed_view', $feed);
}
url: '/publishlinks/publish',with a relative path? Also you can add a failure callback to the ajax function: api.jquery.com/jQuery.ajax