I'm trying to validate my form and I have verified that the array is being sent back to the function but if statement is not working. Again I have looked at the response being sent back and it is set
it is the ifstatement if( test != "false")
json response
{"error":"true","id":62}
default.js
$(".create").click(function (event) {
event.preventDefault();
$("#create-page").dialog({
buttons: {
"Create": function () {
var ed = tinyMCE.get('c_page_content');
var page_headline = $("#page_headline").val();
var page_title = $("#page_title").val();
var description = $("#description").val();
var keywords = $("#keywords").val();
var page_content = ed.getContent();
var id = $("#id").val();
var addItem = $('div[id="contentBox"]:last');
$.post("submit", {
page_headline: page_headline,
page_title: page_title,
description: description,
keywords: keywords,
id: id,
page_content: page_content
}, function (result) {
var test = result.error;
if (test != "false") {
addItem.append('<div class="contentBox ui-widget-content"><div class="cHeader">' + page_title + '</div><div class="cOption"><a href="create" class="edit" id="edit" rel="' + result.id + '">Edit</a></div><div class="cOption"><a href="json_del" class="delete" id="delete" rel="' + result.id + '">Delete</a></div></div>');
$(this).dialog("close");
alert("Page created successfully!");
} else {
$("#title_error").val(result.page_title);
$("#content_error").val(result.page_content);
if(result.page_title !== "")
{
$( 'p[id=title_error]' ).show();
}
if(result.page_content !== "")
{
$( 'p[id=title_error]' ).show();
}
}
});
},
Cancel: function () {
$(this).dialog("close");
}
}
});
$("#create-page").dialog("open");
});