How to remove defaults in Jquery smoothState?

111 Views Asked by At

I'm currently designing a page and using jquery.smoothstate.js.

According to: https://github.com/miguel-perez/smoothState.js?files=1

There's a way to remove the default values, but I can't find it.

Because of this js. I can't run

<form id="form" action="https://gc.synxis.com/rez.aspx?Hotel=0000&Chain=00000&template=RBE&shell=RBE" method="POST" target="_self">

And keeps sending me:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource

If I disable this js, everything seems to work fine, but I need this js to run my animations.

2

There are 2 best solutions below

2
AudioBubble On BEST ANSWER

Edit: Have you tried to add the specific class lists to the smoothState.js blacklist?

Initialized smoothState.js like this:

blacklist: '#form'

The error occurred because of the same-origin policy:

https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy

What will cause this error message: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource


Some information: JSONP is a communication technique used in JavaScript programs running in web browsers to request data from a server in a different domain, something prohibited by typical web browsers because of the same-origin policy.

JSONP takes advantage of the fact that browsers do not enforce the same-origin policy on script tags. Note that for JSONP to work, a server must know how to reply with JSONP-formatted results. JSONP does not work with JSON-formatted results.

Links: Have a look at wikipedia JSONP

How to fix this? I would really prefer using jQuery where you can add dataType : 'jsonp'. This will solve the request error.

Some jQuery code:

   $.ajax({
        type: "GET",
        url: 'https://gc.synxis.com/rez.aspx?Hotel=0000&Chain=00000&template=RBE&shell=RBE',
        async:true,
        dataType : 'jsonp',   //add this data type
        crossDomain:true,
        success: function(data, status, xhr) {
            alert(xhr);
        }
    });
0
Luis Garcia On

Just found the answer:

https://github.com/miguel-perez/smoothState.js/issues/311

I just had to add the blacklist class to my form, to prevent smoothState to run on it!