submit form with json in Bootstrap

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
dotphp
Forum Commoner
Posts: 25
Joined: Sat Nov 10, 2007 8:03 am

submit form with json in Bootstrap

Post by dotphp »

In Bootstrap I have the following piece of code that validate all the fields in the form:

Code: Select all

        /**
         * Called when all validations are completed
         */
        _submit: function() {
            var isValid   = this.isValid(),
                eventType = isValid ? this.options.events.formSuccess : this.options.events.formError,
                e         = $.Event(eventType);

            this.$form.trigger(e);

            // Call default handler
            // Check if whether the submit button is clicked
            if (this.$submitButton) {
                isValid ? this._onSuccess(e) : this._onError(e) ;
										

            }
        },

What I want is if it's success (this._onSuccess(e)) to submit the form with the following code json:

Code: Select all


$("document").ready(function(){
							 
  $(".js-ajax-php-json").submit(function(){
										   
    var data = {
      "action": "test"
    };
    data = $(this).serialize() + "&" + $.param(data);
    $.ajax({
      type: "POST",
      dataType: "json",
      url: "https://www.telekom.ro/delivery/formAction/fix-mobil/response.php", //Relative or absolute path to response.php file
      data: data,
      success: function(data) {
		  
        $(".the-return").html(
          //"Favorite beverage: " + data["favorite_beverage"] + "<br />Favorite restaurant: " + data["favorite_restaurant"] + "<br />Gender: " + data["gender"] + "<br />JSON: " + data["json"]
		  data["ok"]
        );
 
         $(".error").html(
		  data["error"]
        );

I tried to replace the "e" from (this._onSuccess(e)) with the code from above but not success. Both code works good individual.
Practicaly I need to submit the form, then all the fields are validated, with that json code.

Can anyone help me please?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: submit form with json in Bootstrap

Post by Weirdan »

As far as I know, bootstrap is a css framework. Did you mean Backbone.js ?
Post Reply