facebook

PHP Login

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #350734 Reply

    hubdavid
    Member

    Hi, i’m new in Mobione and i have a question:
    I need to create an login form to on a php server via post or get mode with those 3 parameters: User. Pass and Token and receive the response in json.
    I’m sure that i need to put here an Api to ther server.

    But i have no idea from where to start! Someone can help me?

    Thanks a lot.

    #350748 Reply

    Code_A
    Member

    Here is a working AJAX example that I found helpful to get me started.

    There is some sample code here on how to send/receiven data in JSON via AJAX.

    Hopefully this helps to get you started.

    #350785 Reply

    hubdavid
    Member

    Code A,
    Thank you for you replay!

    I learned in the links that you posted, but i’m still lose!

    I cannot understand how can i create a json file in Mobione to access the an php server with user and pass parameters…..
    How can i put a json inside of Mobione?

    Thank You.

    #350789 Reply

    Code_A
    Member

    Here is an example of how to send your parameters in json format (see the 4th line of code).

    var postVar = "something to pass";
    var postVar2 = "something else to pass";
    var url = "http://<your_web_service>/format/json";  //example url ()web service will return data in json format)
    var send = JSON.parse('{"var" : "'+ postVar +'","var2" : "'+ postVar2 +'"}'); //sending parameters to web service in json format)
    response = sendRequest(url, "POST", "json","application/x-www-form-urlencoded; charset=UTF-8", false, send );  

    Here is the AJAX function that send/receive the data.

    function sendRequest(cmd, method, data, content, sync, send){
    
       if (send){
          //post data
          var webReq = jQuery.ajax({url: cmd,type: method,dataType : data,contentType : content, async : sync, data : send});
       }else{
          var webReq = jQuery.ajax({url: cmd,type: method,dataType : data,contentType : content, async : sync});
       }
          webReq.done(function( webText, status, jqXHR ) {
          // Process incoming data here
          response = webText;
          return;
       });   
          
       webReq.fail(function( jqXHR, status, errorThrown ) {
          response = false;
          return;
       });
       
       webReq.always(function( jqXHR, status, errorThrown ) {
       return;
       });
       
       return response;
    }
    
Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: PHP Login

You must be logged in to post in the forum log in