locked
ajax

    Question

  • can you build Windows Store Apps with HTML5 and Ajax calling a php page to connect and query MySql database?  I'm looking to build an app that I can deploy easily in different mobile OS(Android and IOS) but trying not to learn more complex languages.

    What is everyone using in terms on using html5 and javascript to call a MySQL query?

    Sorry, new to this.  Help is really appreciated.

    Tuesday, November 20, 2012 5:21 PM

Answers

  • I read 2 different scenario's from your first question...both can be answered with: WinJS.xhr function

    U can use this function (it looks like the jQuery $.ajax) to either load html and add that to the Windows Store App in runtime or u could use it to load data and bind that data to any controls u have in your Windows Store App. For the MySQL part, it doesn't really matter what data source php is using because u will never see that in your app (not in your Windows Store, iOS or Android app)

    Your second question, HTML5 & JavaScript are a great combination, but u can not call MySQL from HTML5/JS directly.

    Did this answered your questions?

    • Proposed as answer by Dave SmitsMVP Wednesday, November 21, 2012 9:07 AM
    • Marked as answer by Song Tian Monday, November 26, 2012 9:14 AM
    Tuesday, November 20, 2012 7:38 PM
  • Hi,

    As Dirksma said. Winjs.xhr is wrapped xmlhttprequest. You could use that as follow:

     function CallData() {
            var person = { 'Name': 'Name'};
            WinJS.xhr({
                type: "POST",
                url: "http://www.xxx.com/WebService.asmx/method",
                headers: { "Content-type": "application/json" },
                data: JSON.stringify(person)
            }).then(function complete(request) {
                var resdata = request.responseText;
            }, function error(er) {
                var err = er.statusText;
            });
        }


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com
    Microsoft One Code Framework

    • Marked as answer by Song Tian Monday, November 26, 2012 9:14 AM
    Wednesday, November 21, 2012 1:47 AM

All replies

  • I read 2 different scenario's from your first question...both can be answered with: WinJS.xhr function

    U can use this function (it looks like the jQuery $.ajax) to either load html and add that to the Windows Store App in runtime or u could use it to load data and bind that data to any controls u have in your Windows Store App. For the MySQL part, it doesn't really matter what data source php is using because u will never see that in your app (not in your Windows Store, iOS or Android app)

    Your second question, HTML5 & JavaScript are a great combination, but u can not call MySQL from HTML5/JS directly.

    Did this answered your questions?

    • Proposed as answer by Dave SmitsMVP Wednesday, November 21, 2012 9:07 AM
    • Marked as answer by Song Tian Monday, November 26, 2012 9:14 AM
    Tuesday, November 20, 2012 7:38 PM
  • thanks for the help.  I'll check WinJS.xhr function
    Wednesday, November 21, 2012 1:33 AM
  • Hi,

    As Dirksma said. Winjs.xhr is wrapped xmlhttprequest. You could use that as follow:

     function CallData() {
            var person = { 'Name': 'Name'};
            WinJS.xhr({
                type: "POST",
                url: "http://www.xxx.com/WebService.asmx/method",
                headers: { "Content-type": "application/json" },
                data: JSON.stringify(person)
            }).then(function complete(request) {
                var resdata = request.responseText;
            }, function error(er) {
                var err = er.statusText;
            });
        }


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com
    Microsoft One Code Framework

    • Marked as answer by Song Tian Monday, November 26, 2012 9:14 AM
    Wednesday, November 21, 2012 1:47 AM