Results 1 to 4 of 4

Thread: Ajax request/response - Get error from error function

Threaded View

  1. #1
    Join Date
    Apr 2011
    Berlin, Germany

    Ajax request/response - Get error from error function

    To all that could give their feedback. An Ajax json request is made with a form submit handler that triggers it.

    After an Ajax json request/response - Get following error from error function: Error: parsererror with message: SyntaxError: Unexpected token d

    Json is seen to be returned in Chrome network tab.

    HTML FORM ----

    <div class="tour" data-daily-price="357">
    <h2>Paris, France Tour</h2>
    $<span id="total">2,499</span> for <span id="nights-count">7</span> Nights

    <form action="tour.json" method="POST">
    <label for="nights">Number of Nights</label>
    <input type="number" name="nights" id="nights" value="7">
    <input type="submit" value="book">

    JS ------

    $(document).ready(function() {
    $('form').on('submit', function(event) {

    $.ajax('tour.json', {
    type: 'POST',
    dataType: 'json',
    data: $('form').serialize(),
    success: function(response) {
    var html = '';

    $.each(response, function(index, entry) {
    html += '<ul>';
    html += '<li>Destination' +entry.description+'</li>';
    html += '<li>Price' +entry.price+'</li>';
    html += '<li>Nights' +entry.nights+ '</li>';
    html += '<li>Confirmation' +entry.confirmation+ '</li>';
    html += '</ul>';
    error: function(request, errorType, errorMessage) {
    console.log('Error: ' + errorType + ' with message: ' + errorMessage);
    contentType: 'application/json'
    Last edited by ab2qik; 03-22-2014 at 07:38 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles