1

URLからjsonを再実行するためにajaxリクエストを使用しています。

これは以下のようにローカルで機能しています:

$.ajax({
            url: "http://localhost:8080/updates.json",      
            type: 'post',
            dataType : "json",
            success : function(jsonResponse) {  
            }); 

            },
            error: function (err) {
            } 

        });

URLは、デプロイされているサーバーに関係なく機能するように更新する必要があります。

URLを次のようなものに置き換えることができます: "http://" + getThisHostName()+ ":8080 / updateds.json"?

現在のホスト名パスを返す安全な方法はありますか?

4

1 に答える 1

2

あなたはこのようにすることができます

//say you are on http://domain.com:8080
//this will request from http://domain.com:8080/updates.json
$.ajax({
    url: "/updates.json", 
    ...
});
于 2012-07-20T13:34:51.370 に答える