开发者

XMLHttpRequest cannot load Chrome error JQuery/Ajax

I am getting this error in chrome

XMLHttpRequest cannot load ttp://www.officeyoganyc.com/lists/?p=subscribe. Cross origin requests are only supported for HTTP.

I am attempting to create an AJAX signup form with PHP list.

the signup form works if it simply posts to the ?p=subscribe url, but when I use the JQuery AJAX call it loads the success message, but the request does not go through.

<form id="newsletter"  method="post" action="ttp://www.officeyoganyc.com/lists/?p=subscribe" name="subscribeform"><input type="hidden" name="formtoken" value="a7d1884b463ed70e91fb62a5121e9846" />


<div class="fieldHolder">
  <div class="attributeinput1"><input type=text name=email value="email" autofocus="autofocus" autocomplete="on" size="12"/> 
  <script language="Javascript" type="text/javascript">addFieldToCheck("email","Email");</script></div> 
  </div>


  <div class="fieldHolder2">
  <div class="attributeinput2"><input type=text name=emailconfirm value="confirm email" autocomplete="off" size="12"/> 
  <script language="Javascript" type="text/javascript">addFieldToCheck("emailconfirm","Confirm your email address");</script></div>
        </div> 
  <input type="hidden" name="list[1]" value="signup"><input type="hidden" name="listname[1]" value="office yoga list"/><div style="display:none"><input type="text" name="VerificationCodeX" 开发者_StackOverflow社区value="" size="20"></div>

<div id="subscribe"><input type=image src="http://www.officeyoganyc.com/themes/zen/zen/images/yogaSubmit.png" id="go" name="subscribe" value="Subscribe"></div>
    </form>


  <script type="text/javascript">
        $(document).ready(function () {
            $('#go').click(function () {
                $.ajax({
                    type: 'POST',
                    data: $('#newsletter').serialize(),
                    url: $('#newsletter').attr('action'),
                    success: alert('yes'),
                })


                return false;
            });

        });
    </script>


You first line misses an h in http.

<form id="newsletter"  method="post" action="ttp://www.officeyoganyc.com/lists/?p=subscribe" name="subscribeform"><input type="hidden" name="formtoken" value="a7d1884b463ed70e91fb62a5121e9846" />

should be

<form id="newsletter"  method="post" action="http://www.officeyoganyc.com/lists/?p=subscribe" name="subscribeform"><input type="hidden" name="formtoken" value="a7d1884b463ed70e91fb62a5121e9846" />


It's restriction of Same origin Policy

http://en.wikipedia.org/wiki/Same_origin_policy

EDIT: Nope... you forgot to add h before your address

<form id="newsletter"  method="post" action="/lists/?p=subscribe" name="subscribeform"><input type="hidden" name="formtoken" value="a7d1884b463ed70e91fb62a5121e9846" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜