- This topic has 3 replies, 2 voices, and was last updated 10 years, 11 months ago by
Code_A.
-
AuthorPosts
-
hubdavidMemberHi, 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.
July 31, 2014 at 8:00 pm #350748
Code_AMemberHere 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.
August 4, 2014 at 3:17 am #350785
hubdavidMemberCode 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.
August 4, 2014 at 6:09 am #350789
Code_AMemberHere 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; }
-
AuthorPosts