loadUrl() not change url and some error #152

Closed
opened 2018-04-25 12:27:40 -05:00 by hanzzame · 6 comments
hanzzame commented 2018-04-25 12:27:40 -05:00 (Migrated from github.com)

i have a problem using loadurl()
if i use pjax.loadUrl("/your-url"); i have a error typeError: options is undefined on line 154:5 pjax.js
this my script

(function ($) {
	'use strict';
    var pjax = new Pjax({
            elements: [".ajax-nav a"],
            cacheBust : false,
            history : true,
            currentUrlFullReload : false,
            selectors: ["header,title,.app,.ajax-footer,.ajax-nav"]
        })
        window.activenav = function () 
        {
        $(".ajax-nav a").each(function () {
                if (this.href == window.location.href) {
                    $(this).addClass("active");
                    $(this).parent().addClass("active"); // add active to li of the current link
                    $(this).parent().parent().prev().addClass("active"); // add active class to an anchor
                    $(this).parent().parent().prev().click(); // click the item to make it drop
                }
        });
      }


        function callFunctionApp() {

          
          var options = { 
            beforeSubmit:  showRequest,  // pre-submit callback 
            success:       showResponse,  // post-submit callback 
            dataType:  'json',       // 'xml', 'script', or 'json' (expected server response type) 
            //clearForm: true,       // clear all form fields after successful submit 
            //resetForm: true        // reset the form after successful submit 
          };
          function showRequest() { 
              $('body').loading({
                message: 'PROSES...'
              });          
          } 
          function showResponse(response)  { 
              $('body').loading('stop');

                if (response.status === 'error'){
                  var icon = 'ti-close';
                  var title = '<strong>Oops!</strong>';
                } else {
                  var icon = 'ti-check';
                  var title = '<strong>Well done!</strong>';
                }
              $.notify({
                  title: title,
                  icon: icon,
                  message: response.message,
                },{
                  type: response.type,
                  allow_dismiss: false,
                  showProgressbar:true,
                  placement: {
                    from: "top",
                    align: "right"
                  },
                  offset: {
                    x : 20,
                    y : 90
                  },
                  timer: 100,
                  animate: {
                    enter: 'animated fadeInRight',
                    exit: 'animated fadeOutRight'
                  }
                }); 

              pjax.loadUrl(response.url);
          } 

          $('form').on('submit', function(e) {
            e.preventDefault(); // prevent native submit
            $(this).ajaxSubmit(options);
          });

          activenav();  
        }
        callFunctionApp()
        document.addEventListener('pjax:complete', callFunctionApp)
})(jQuery);

if i comment //options.requestOptions.timeout = this.options.timeout inline 154 page is load but url not change.

how to fix this.
Thanks.

i have a problem using loadurl() if i use `pjax.loadUrl("/your-url");` i have a error `typeError: options is undefined on line 154:5 pjax.js` this my script ``` (function ($) { 'use strict'; var pjax = new Pjax({ elements: [".ajax-nav a"], cacheBust : false, history : true, currentUrlFullReload : false, selectors: ["header,title,.app,.ajax-footer,.ajax-nav"] }) window.activenav = function () { $(".ajax-nav a").each(function () { if (this.href == window.location.href) { $(this).addClass("active"); $(this).parent().addClass("active"); // add active to li of the current link $(this).parent().parent().prev().addClass("active"); // add active class to an anchor $(this).parent().parent().prev().click(); // click the item to make it drop } }); } function callFunctionApp() { var options = { beforeSubmit: showRequest, // pre-submit callback success: showResponse, // post-submit callback dataType: 'json', // 'xml', 'script', or 'json' (expected server response type) //clearForm: true, // clear all form fields after successful submit //resetForm: true // reset the form after successful submit }; function showRequest() { $('body').loading({ message: 'PROSES...' }); } function showResponse(response) { $('body').loading('stop'); if (response.status === 'error'){ var icon = 'ti-close'; var title = '<strong>Oops!</strong>'; } else { var icon = 'ti-check'; var title = '<strong>Well done!</strong>'; } $.notify({ title: title, icon: icon, message: response.message, },{ type: response.type, allow_dismiss: false, showProgressbar:true, placement: { from: "top", align: "right" }, offset: { x : 20, y : 90 }, timer: 100, animate: { enter: 'animated fadeInRight', exit: 'animated fadeOutRight' } }); pjax.loadUrl(response.url); } $('form').on('submit', function(e) { e.preventDefault(); // prevent native submit $(this).ajaxSubmit(options); }); activenav(); } callFunctionApp() document.addEventListener('pjax:complete', callFunctionApp) })(jQuery); ``` if i comment `//options.requestOptions.timeout = this.options.timeout` inline 154 page is load but url not change. how to fix this. Thanks.
BehindTheMath commented 2018-04-25 12:34:55 -05:00 (Migrated from github.com)

This is a duplicate of #127.

This has been fixed and will be released with v0.2.6. Until then, you can use the workaround mentioned in #127.

This is a duplicate of #127. This has been fixed and will be released with v0.2.6. Until then, you can use the workaround mentioned in #127.
BehindTheMath commented 2018-04-25 12:37:42 -05:00 (Migrated from github.com)

Regarding the URL not changing, does the new page load?

Regarding the URL not changing, does the new page load?
hanzzame commented 2018-04-25 12:40:56 -05:00 (Migrated from github.com)

yes new page is load, only url not change.

yes new page is load, only url not change.
BehindTheMath commented 2018-04-25 16:05:56 -05:00 (Migrated from github.com)

Can you try with the latest version from Github? Clone the repo, and run npm run build.

Can you try with the latest version from Github? Clone the repo, and run `npm run build`.
hanzzame commented 2018-04-25 21:54:44 -05:00 (Migrated from github.com)

Hallo,

this problem solved thanks for your support
i follow instruction in #127 and npm run build

is this can support submit/upload image enctype="multipart/form-data"?

Thanks you.

Hallo, this problem solved thanks for your support i follow instruction in #127 and `npm run build` is this can support submit/upload image `enctype="multipart/form-data"`? Thanks you.
BehindTheMath commented 2018-04-25 21:57:39 -05:00 (Migrated from github.com)

this problem solved thanks for your support
i follow instruction in #127 and npm run build

Great. We hope to release v0.2.6 soon, which will include this fix.

is this can support submit/upload image enctype="multipart/form-data"?

Right now, no, but it's the next thing on my to do list. See #132.

>this problem solved thanks for your support i follow instruction in #127 and npm run build Great. We hope to release v0.2.6 soon, which will include this fix. >is this can support submit/upload image enctype="multipart/form-data"? Right now, no, but it's the next thing on my to do list. See #132.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: iLoveElysia/pjax#152