使用ajax从视图(html页面)调用服务器的功能,URL不起作用

时间:2017-05-18 13:56:48

标签: javascript jquery ajax ionic2 angular2-routing

我正在开发ionic2应用程序,这是我当地的PC细节 -

******************************************************
Your system information:

Cordova CLI: 6.4.0 
Ionic Framework Version: 2.0.0-beta.10
Ionic CLI Version: 2.1.8
Ionic App Lib Version: 2.1.4
ios-deploy version: Not installed
ios-sim version: 5.0.8 
OS: OS X Yosemite
Node Version: v6.2.2
Xcode version: Xcode 7.2 Build version 7C68

******************************************************

我想使用AJAX从视图(网页)调用服务器的功能 -

server-page.ts -

public myFunction(param1, param2) {
     code goes here... ;
}

some-page.html

    function onClickMe(param1, param2) {
      $.ajax({
        url: "/../../../../app/pages/server/server-page.ts",
        // url: "/../../../app/pages/server/server-page.ts",
        // url: "/../../app/pages/server/server-page.ts",
        // url: "/app/pages/server/server-page.ts",
        // url: "http://localhost:8100/app/pages/server/server-page.ts",
        type: "POST",
        //data: jQuery.param({ firstParam: param1, secondParam : param2}),
        data: 'some data to pass',
        contentType: " charset=utf-8",
        success: function (response) {
          alert(response.status);
        },
        error: function () {
          alert("error page not Found");
        }
      });
    }

我也使用了所有评论网址,我不知道该怎么做 每当我调用该函数时,我都会收到错误as-

http://localhost:8100/app/pages/server/server-page.ts 404 (Not Found)  

时间不见了,我被困了,帮帮我!!!

提前致谢!!!

0 个答案:

没有答案