0

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 Answers2

0

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);
        }
    });
  • I get what you are trying to say and you got a point of the same origin policy. The problem is that Im running locally. For example let's say I put my
    in a plain html - it works. But in the actual page because of something in smoothState.js (trying to figure it out, what it is) is blocking the form and send the Cross-Origin Request Blocked instead. Im not getting information from the external page, im sending it!
    – Luis Garcia Mar 09 '18 at 19:07
  • Oh I see. Yeah your right, I was facing the same issue during my tests. See my edit above@LuisGarcia `:)` –  Mar 09 '18 at 19:37
0

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!