weixin_33735676 2011-08-10 20:43 采纳率: 0%
浏览 44

使用AJAX的漂亮网址

I'm using jQuery to ajax a few items on my page. When I go to one of the pretty URL's that the htaccess file makes, it error's out. Here's the jQuery code I'm currently using:

    $.ajax({
        url: "inc/file.php",
        success: function(result){
        $('#NavMoreInfo').html(result);
        navMoreInfoCloseButton();
        $(":not(#NavMoreInfo)").click(function() {
            $('#NavMoreInfo').slideUp(300);
        }); 
        },
        error: function(event, request){
            alert(request);
        }

Here's my htaccess file:

    DirectoryIndex master.php
    # Enable Rewriting
    RewriteEngine on

    RewriteRule ^main/?$ master.php
    RewriteRule ^(\w+)/?$ master.php?page=$1

How can I crossDomain my jQuery AJAX? Or is it something in my htaccess that I need to change? Any help is appreciated!

Thank you.

  • 写回答

2条回答 默认 最新

  • 零零乙 2011-08-10 20:52
    关注

    See jquery ajax documentation, for crossdomain requests :

    crossDomain(added 1.5) Default: false for same-domain requests, true for cross-domain requests

    If you wish to force a crossDomain request (such as JSONP) on the same domain, set the value of crossDomain to true. This allows, for example, server-side redirection to another domain.

    UPDATE **

    You need to provide the FULL url of the requested website . This includes http:// or https://

    in your case "http://www.mysite.com/inc/file.php"

    评论

报告相同问题?