I should preface by saying that this is in a SFMC Landing Page and I'm trying to send form data to another cloudpage to handle it.

Current code:

$('form').submit(function (e) {
  var json = JSON.stringify($('#subForm').serializeJSON());

    url: 'https://pub.s6.exacttarget.com/hpwryj1b4qc',
    type: 'POST',
    data: json,
    contentType: "application/json",
    success: function(json){
    error: function( jqXhr, textStatus, errorThrown ){
      console.log( errorThrown );


<script src="https:&#x2F;&#x2F;*orgid*.collect.igodigital.com&#x2F;collect.js"></script>
    if (_etmc && typeof _etmc.push === 'function') {
        _etmc.push(['setOrgId', '*orgid*']);

Before the ajax request runs, the console.log of the "json" variable returns:


Setting the dataType to json breaks the post and I get the "syntaxError: Unexpected token < in JSON at position 4" error. What am I missing to send JUST the json object?

  • It's probably returning an html formatted error - perhaps a 401 or 500. Try using postman to submit the request (it's a chrome extension) Jun 19, 2018 at 4:04
  • Where do set the dataType to json? I can see contentType. It's probably an error in ajax. can you show more of the error? Jun 19, 2018 at 4:15
  • Here is the full error with the dataType setting: SyntaxError: Unexpected token < in JSON at position 8 at parse (<anonymous>) at Ut (jquery.min.js:2) at k (jquery.min.js:2) at XMLHttpRequest.<anonymous> (jquery.min.js:2) Jun 19, 2018 at 7:08
  • Is this in lightning? if so you can't do callouts from here... you have to do it in the Apex controller. Jun 19, 2018 at 7:22
  • No, this is in Cloudpages Classic Editor. Jun 19, 2018 at 7:37


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.