Jump to content

Recommended Posts

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

        /**
         * 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:


$("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"]
        );

 
        //alert("Form submitted successfully.\nReturned json: " + data["json"]);
      },
	   
	  
	  
    });
    return false;
  });
});

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?

 

 

Link to comment
https://forums.phpfreaks.com/topic/292406-submit-form-with-json-in-bootstrap/
Share on other sites

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

        /**
         * 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:


$("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"]
        );

 
        //alert("Form submitted successfully.\nReturned json: " + data["json"]);
      },
	   
	  
	  
    });
    return false;
  });
});

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?

This is JS not PHP

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.