Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

I have a super simple safecracker form in my header (embedded template). It's literally 1 field. I'm using the ajax example in the ee docs (http://ellislab.com/expressionengine/user-guide/modules/safecracker/examples.html#ajax-driven-entry-form).

The form works everywhere except the home page. I get readyState: 4 which I read (http://stackoverflow.com/questions/5852257/jquery-s-ajax-error-handler-being-executed-if-readystate-4-and-status-200https://stackoverflow.com/questions/5852257/jquery-s-ajax-error-handler-being-executed-if-readystate-4-and-status-200) means the returned json is malformed. It's true because the responseText is the code for the home page.

I've changed "Make the index template in this group your site's home page?" to a different template group and then the original home page works and this new temp home page fails.

My safecracker opening:

{exp:safecracker json="yes" 
channel="email_submission" id="email-subscribe" logged_out_member_id="2" 
datepicker="no" include_jquery="no" safecracker_head="no"}

And my js:

$('#email-subscribe').ajaxForm({
    dataType: 'json',
    success: function(data) {
        if (data.success) {
            alert('You successfully added a new entry with entry_id '+data.entry_id)
        } else {
            alert('Failed with the following errors: '+ JSON.stringify(data.errors));
        }
    },
    error: function(data) {
        // this is what's coming up
        alert('Failed with the following errors: '+ JSON.stringify(data));
    }
});

Has anyone encountered anything like this before? Any suggestions? I feel like I'm taking crazy pills.

Thanks Amanda

I have a super simple safecracker form in my header (embedded template). It's literally 1 field. I'm using the ajax example in the ee docs (http://ellislab.com/expressionengine/user-guide/modules/safecracker/examples.html#ajax-driven-entry-form).

The form works everywhere except the home page. I get readyState: 4 which I read (http://stackoverflow.com/questions/5852257/jquery-s-ajax-error-handler-being-executed-if-readystate-4-and-status-200) means the returned json is malformed. It's true because the responseText is the code for the home page.

I've changed "Make the index template in this group your site's home page?" to a different template group and then the original home page works and this new temp home page fails.

My safecracker opening:

{exp:safecracker json="yes" 
channel="email_submission" id="email-subscribe" logged_out_member_id="2" 
datepicker="no" include_jquery="no" safecracker_head="no"}

And my js:

$('#email-subscribe').ajaxForm({
    dataType: 'json',
    success: function(data) {
        if (data.success) {
            alert('You successfully added a new entry with entry_id '+data.entry_id)
        } else {
            alert('Failed with the following errors: '+ JSON.stringify(data.errors));
        }
    },
    error: function(data) {
        // this is what's coming up
        alert('Failed with the following errors: '+ JSON.stringify(data));
    }
});

Has anyone encountered anything like this before? Any suggestions? I feel like I'm taking crazy pills.

Thanks Amanda

I have a super simple safecracker form in my header (embedded template). It's literally 1 field. I'm using the ajax example in the ee docs (http://ellislab.com/expressionengine/user-guide/modules/safecracker/examples.html#ajax-driven-entry-form).

The form works everywhere except the home page. I get readyState: 4 which I read (https://stackoverflow.com/questions/5852257/jquery-s-ajax-error-handler-being-executed-if-readystate-4-and-status-200) means the returned json is malformed. It's true because the responseText is the code for the home page.

I've changed "Make the index template in this group your site's home page?" to a different template group and then the original home page works and this new temp home page fails.

My safecracker opening:

{exp:safecracker json="yes" 
channel="email_submission" id="email-subscribe" logged_out_member_id="2" 
datepicker="no" include_jquery="no" safecracker_head="no"}

And my js:

$('#email-subscribe').ajaxForm({
    dataType: 'json',
    success: function(data) {
        if (data.success) {
            alert('You successfully added a new entry with entry_id '+data.entry_id)
        } else {
            alert('Failed with the following errors: '+ JSON.stringify(data.errors));
        }
    },
    error: function(data) {
        // this is what's coming up
        alert('Failed with the following errors: '+ JSON.stringify(data));
    }
});

Has anyone encountered anything like this before? Any suggestions? I feel like I'm taking crazy pills.

Thanks Amanda

Source Link

safecracker + ajax = readyState: 4 on home page

I have a super simple safecracker form in my header (embedded template). It's literally 1 field. I'm using the ajax example in the ee docs (http://ellislab.com/expressionengine/user-guide/modules/safecracker/examples.html#ajax-driven-entry-form).

The form works everywhere except the home page. I get readyState: 4 which I read (http://stackoverflow.com/questions/5852257/jquery-s-ajax-error-handler-being-executed-if-readystate-4-and-status-200) means the returned json is malformed. It's true because the responseText is the code for the home page.

I've changed "Make the index template in this group your site's home page?" to a different template group and then the original home page works and this new temp home page fails.

My safecracker opening:

{exp:safecracker json="yes" 
channel="email_submission" id="email-subscribe" logged_out_member_id="2" 
datepicker="no" include_jquery="no" safecracker_head="no"}

And my js:

$('#email-subscribe').ajaxForm({
    dataType: 'json',
    success: function(data) {
        if (data.success) {
            alert('You successfully added a new entry with entry_id '+data.entry_id)
        } else {
            alert('Failed with the following errors: '+ JSON.stringify(data.errors));
        }
    },
    error: function(data) {
        // this is what's coming up
        alert('Failed with the following errors: '+ JSON.stringify(data));
    }
});

Has anyone encountered anything like this before? Any suggestions? I feel like I'm taking crazy pills.

Thanks Amanda