Announcement

Collapse
No announcement yet.

After the Ajax post

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • After the Ajax post

    I am redirecting to the post-Ajax post creation page. After redirecting, I want to auto-fill the name field on the build page with the data I get from ajax. Is this possible ?

    Code example;
    Code:
    $.ajax({
        url: 'Meeting/action/Test',
        type: 'POST',
        data: JSON.stringify({
            phone: phone
        }),
        success: function (data) {                        
            if(data.status == 409){                            
                console.log("duplicate");
            }else{
                // I want auto-fill name field. ?
                window.location = '#Meeting/create';                            
                self.close();
            }
        }
    });

  • #2
    Hi,
    EspoCRM – Open Source CRM Application. Contribute to espocrm/espocrm development by creating an account on GitHub.

    Comment


    • #3
      Thanks for quick reply. tanya

      But I use click event

      Code:
      events: {
          'click #gonder': function (e) {
              var self = this;
      
              var $phone = this.$el.find('input[name="phone"]');                
              var phone = $phone.val();
      
              $.ajax({
                  url: 'Meeting/action/Test',
                  type: 'POST',
                  data: JSON.stringify({
                      phone: phone
                  }),
                  success: function (data) {                        
                      if(data.status == 409){                            
                          self.$el.find('#duplicate').removeClass('hidden');
                      }else{                            
                          window.location = '#Meeting/create';                            
                          self.close();
                      }
                  }
              });
          }
      },
      How do I do it here? Could you give a simple example?

      Comment


      • #4
        ? I show you a method, which navigate to other url with set attributes. Build your attributes and options go to your page with router
        window.location - is not the best solution for single page application

        Comment


        • #5
          I understand. I will do this. Thank you. tanya

          Comment


          • #6
            I did what you said, but I can not find the functions. tanya

            Uncaught TypeError: this.getRouter is not a function , model, fetch vs..
            They can not find any of them.

            Comment


            • #7
              self.getRouter() ?

              Comment


              • #8
                Yes, it works that way. But the others are not working. tanya

                Uncaught TypeError: Cannot read property 'fetch' of undefined.
                Uncaught TypeError: Cannot read property 'model' of undefined

                Comment


                • #9
                  is a view valid? commas and '(', '{', '}', ')'

                  Comment


                  • #10
                    Originally posted by tanya View Post
                    is a view valid? commas and '(', '{', '}', ')'
                    Here is all I do.

                    Code:
                    events: {
                        'click #gonder': function (e) {
                            var self = this;
                    
                            var $phone = this.$el.find('input[name="phone"]');                
                            var phone = $phone.val();
                            var router = this.getRouter();
                    
                            $.ajax({
                                url: 'Meeting/action/Test',
                                type: 'POST',
                                data: JSON.stringify({
                                    phone: phone
                                }),
                                success: function (data) {
                                    var url;
                                    var router = self.getRouter();                        
                                    url = '#' + 'Meeting' + '/create';
                    
                                    window.location = url;
                                    var attributes = self.getView('edit').fetch();
                                    var model = self.getView('edit').model;
                                    attributes = _.extend(attributes, model.getClonedAttributes());
                    
                                    console.log(model);
                    
                                    self.close();
                                }
                            });
                        }
                    },
                    It gives this error.

                    Uncaught TypeError: Cannot read property 'fetch' of undefined or model.

                    Comment


                    • #11
                      Do you understand the problem? tanya

                      Comment


                      • #12
                        Originally posted by gundogduyakici View Post
                        I am redirecting to the post-Ajax post creation page. After redirecting, I want to auto-fill the name field on the build page with the data I get from ajax. Is this possible ?

                        Code example;
                        Code:
                        $.ajax({
                        url: 'Meeting/action/Test',
                        type: 'POST',
                        data: JSON.stringify({
                        phone: phone
                        }),
                        success: function (data) {
                        if(data.status == 409){
                        console.log("duplicate");
                        }else{
                        // I want auto-fill name field. ?
                        window.location = '#Meeting/create';
                        self.close();
                        }
                        }
                        });
                        Faced the same problem.
                        Can you tell how you solved this problem?

                        Comment

                        Working...
                        X