Forum Moderators: open
I can send the request to a script outside of the MVC app just fine, but as soon as I try to send it to a page inside the MVC app it fails. The page I try to send to is :
http://www.example.com/content/create_page - Where create_page is a public method of a class.
Another problem is on the page that works, even if I simply return false I always get success from JQuery. I would really like to use this within the MVC app since I can reuse my database isntance and access all my helpers in validating data.
Is this at all possible? Here is my JQuery code...
$(document).ready(function(){// Hide status message by default
$(".error").hide();
$("#error").hide();
$("#success").hide();
// Create content
$("#submit").click(function(){
// Hide status message by default
//$("#error").hide();
//$("#success").hide();
var hasError = false;
// Check that we have a title
var title = $("#title").val();
if(title == '') {
$("#title_error").show();
hasError = true;
}
// Check that we have a url
var url = $("#url").val();
if(url == '') {
$("#url_error").show();
hasError = true;
}
// Check that the full story and short story was not left blank
var short = $('#short').val();
var full = $('#full').val();
if(short == '' && full == '') {
$("#short_error").show();
$("#full_error").show();
hasError = true;
}
// Get form data
var formData = $('#create_form').serialize();
// Check that we dont have errors
if(hasError == false) {
$(this).hide();
$.ajax({
type: "POST",
url: "http://localhost/framework2/public/js/ajax/php/content_create.php",
data: formData,
cache: false,
success: function(){
$('#success').fadeIn("slow");
},
error: function() {
$('#error').fadeIn("slow");
}
});
}
else {
$('#error').fadeIn("slow");
$(this).show();
}
return false;
});
});
[edited by: Fotiman at 6:34 pm (utc) on Jan. 11, 2010]
[edit reason] Examplified URL [/edit]