FAQ
Hey guys, I am really stuck with that problem. I have a JQuery Dialog which
contains a selectbox. When I change the option inside this selectbox,
another selectbox shows up with options generated from an .ajax() event.
Anyway... everything works fine, but when I submit the form CakePHP says:
404 Bad Request - URL was not found, but it DOES EXISTS 100%. I tested it
several times to be sure, but another thing is: When submit the form
WITHOUT selecting any option from the first selectbox the form is submitted
correctly. I dont know what to post really but here is my Javascript:

$('select[data-onchange=true]').live("change", function() {
var _this = $(this);
var element = $('select[data-onchange-trigger=' + _this.attr("id")
+ ']:first');

if (typeof element == "object") {
if (_this.attr("data-onchange-load")) {
var options = element.prop("options");
var load = _this.attr("data-onchange-load");
$.ajax({
dataType: "json",
url: load + _this.find('option:selected').val(),
beforeSend: function() {
$('.ajax-loader').show();
element.find('option').remove();
element.parent().hide();
},
success: function(data) {
$.each(data, function(index, _data) {
if (typeof _data == "object") {
$.each(_data, function(index, _data) {
options[options.length] = new
Option(_data.name, _data.id);
});
}
});
element.parent().show();
},
complete: function() {
$('.ajax-loader').hide();
}
});
}
}
});
The error occurs only when I submit the form after I change the option on
the selectbox.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.

Search Discussions

  • Lowpass at Nov 17, 2012 at 7:02 pm
    Cake throws a 404 when debugging is disabled. You probably have an
    error somewhere in your PHP, not the JS.
    On Fri, Nov 16, 2012 at 1:53 AM, Benjamin Such wrote:
    Hey guys, I am really stuck with that problem. I have a JQuery Dialog which
    contains a selectbox. When I change the option inside this selectbox,
    another selectbox shows up with options generated from an .ajax() event.
    Anyway... everything works fine, but when I submit the form CakePHP says:
    404 Bad Request - URL was not found, but it DOES EXISTS 100%. I tested it
    several times to be sure, but another thing is: When submit the form WITHOUT
    selecting any option from the first selectbox the form is submitted
    correctly. I dont know what to post really but here is my Javascript:
    $('select[data-onchange=true]').live("change", function() {

    var _this = $(this);
    var element = $('select[data-onchange-trigger=' + _this.attr("id")
    + ']:first');

    if (typeof element == "object") {
    if (_this.attr("data-onchange-load")) {
    var options = element.prop("options");
    var load = _this.attr("data-onchange-load");
    $.ajax({
    dataType: "json",
    url: load + _this.find('option:selected').val(),
    beforeSend: function() {
    $('.ajax-loader').show();
    element.find('option').remove();
    element.parent().hide();
    },
    success: function(data) {
    $.each(data, function(index, _data) {
    if (typeof _data == "object") {
    $.each(_data, function(index, _data) {
    options[options.length] = new
    Option(_data.name, _data.id);
    });
    }
    });
    element.parent().show();
    },
    complete: function() {
    $('.ajax-loader').hide();
    }
    });
    }
    }
    });

    The error occurs only when I submit the form after I change the option on
    the selectbox.

    --
    Like Us on FaceBook https://www.facebook.com/CakePHP
    Find us on Twitter http://twitter.com/CakePHP

    ---
    You received this message because you are subscribed to the Google Groups
    "CakePHP" group.
    To post to this group, send email to [email protected].
    To unsubscribe from this group, send email to
    [email protected].
    Visit this group at http://groups.google.com/group/cake-php?hl=en.
    --
    Like Us on FaceBook https://www.facebook.com/CakePHP
    Find us on Twitter http://twitter.com/CakePHP

    ---
    You received this message because you are subscribed to the Google Groups "CakePHP" group.
    To post to this group, send email to [email protected].
    To unsubscribe from this group, send email to [email protected].
    Visit this group at http://groups.google.com/group/cake-php?hl=en.
  • Rob M at Nov 18, 2012 at 1:09 pm
    A. To debug, I'd insert the line:
    console.log(load + _this.find('option:selected').val());
    just above your $.ajax() call. Then watch your Javascript console when
    running the page to see what URL is being submitted and try submitting it
    manually.
    - Rob
    On Friday, November 16, 2012 1:53:13 AM UTC-5, Benjamin Such wrote:

    Hey guys, I am really stuck with that problem. I have a JQuery Dialog
    which contains a selectbox. When I change the option inside this selectbox,
    another selectbox shows up with options generated from an .ajax() event.
    Anyway... everything works fine, but when I submit the form CakePHP says:
    404 Bad Request - URL was not found, but it DOES EXISTS 100%. I tested it
    several times to be sure, but another thing is: When submit the form
    WITHOUT selecting any option from the first selectbox the form is submitted
    correctly. I dont know what to post really but here is my Javascript:

    $('select[data-onchange=true]').live("change", function() {
    var _this = $(this);
    var element = $('select[data-onchange-trigger=' +
    _this.attr("id") + ']:first');

    if (typeof element == "object") {
    if (_this.attr("data-onchange-load")) {
    var options = element.prop("options");
    var load = _this.attr("data-onchange-load");
    $.ajax({
    dataType: "json",
    url: load + _this.find('option:selected').val(),
    beforeSend: function() {
    $('.ajax-loader').show();
    element.find('option').remove();
    element.parent().hide();
    },
    success: function(data) {
    $.each(data, function(index, _data) {
    if (typeof _data == "object") {
    $.each(_data, function(index, _data) {
    options[options.length] = new Option(_
    data.name, _data.id);
    });
    }
    });
    element.parent().show();
    },
    complete: function() {
    $('.ajax-loader').hide();
    }
    });
    }
    }
    });
    The error occurs only when I submit the form after I change the option on
    the selectbox.
    --
    Like Us on FaceBook https://www.facebook.com/CakePHP
    Find us on Twitter http://twitter.com/CakePHP

    ---
    You received this message because you are subscribed to the Google Groups "CakePHP" group.
    To post to this group, send email to [email protected].
    To unsubscribe from this group, send email to [email protected].
    Visit this group at http://groups.google.com/group/cake-php?hl=en.
  • Sophistry at Nov 19, 2012 at 6:37 pm
    have you checked the CSRF setting in the security component? - you would
    not be the first one to be tripped-up by the Form helper security token
    regimen when trying to use ajax forms.
    On Friday, November 16, 2012 1:53:13 AM UTC-5, Benjamin Such wrote:

    Hey guys, I am really stuck with that problem. I have a JQuery Dialog
    which contains a selectbox. When I change the option inside this selectbox,
    another selectbox shows up with options generated from an .ajax() event.
    Anyway... everything works fine, but when I submit the form CakePHP says:
    404 Bad Request - URL was not found, but it DOES EXISTS 100%. I tested it
    several times to be sure, but another thing is: When submit the form
    WITHOUT selecting any option from the first selectbox the form is submitted
    correctly. I dont know what to post really but here is my Javascript:

    $('select[data-onchange=true]').live("change", function() {
    var _this = $(this);
    var element = $('select[data-onchange-trigger=' +
    _this.attr("id") + ']:first');

    if (typeof element == "object") {
    if (_this.attr("data-onchange-load")) {
    var options = element.prop("options");
    var load = _this.attr("data-onchange-load");
    $.ajax({
    dataType: "json",
    url: load + _this.find('option:selected').val(),
    beforeSend: function() {
    $('.ajax-loader').show();
    element.find('option').remove();
    element.parent().hide();
    },
    success: function(data) {
    $.each(data, function(index, _data) {
    if (typeof _data == "object") {
    $.each(_data, function(index, _data) {
    options[options.length] = new Option(_
    data.name, _data.id);
    });
    }
    });
    element.parent().show();
    },
    complete: function() {
    $('.ajax-loader').hide();
    }
    });
    }
    }
    });
    The error occurs only when I submit the form after I change the option on
    the selectbox.
    --
    Like Us on FaceBook https://www.facebook.com/CakePHP
    Find us on Twitter http://twitter.com/CakePHP

    ---
    You received this message because you are subscribed to the Google Groups "CakePHP" group.
    To post to this group, send email to [email protected].
    To unsubscribe from this group, send email to [email protected].
    Visit this group at http://groups.google.com/group/cake-php?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcake-php @
categoriesphp
postedNov 17, '12 at 12:41a
activeNov 19, '12 at 6:37p
posts4
users4
websitecakephp.org
irc#cakephp

People

Translate

site design / logo © 2023 Grokbase