2

I have to call the web service using java script? e.g. I'm creating one app in HTML. In that I want to check user name and password in server machine(computer) and I want to collect the result from the server. Here I'm passing three arguments like user name, password and login mode(windows or others) then it's sent to server and it returns json result then I parse the json result and then I'm binding in to a list. so I got output in jQuery.

// Make the dataobject based on the credentials 
            var dataObject = {}; 
dataObject = {Username:uname,Password:pword,Domain:domain,WindowsUser:windowsuser};

//webservice

$.ajax({
        type: "POST", 
        url:"../REST/session.aspx?_method=put",
        data: JSON.stringify(dataObject, null,4),
        cache: false,
        dataType: "json",
        success: onSuccessLogin,
        error: function (xhr, ajaxOptions){
                alert(xhr.status + " : " + xhr.statusText);
            }    

    }); 

function onSuccessLogin(data)
{

    alert("success");
    $.mobile.pageLoading();

    //Parse the vault result
    parseResults(data);
}

then I successfully parsed. Here I want to change the web service because Non touch mobiles doesn't support the jQuery. so that I'm changing that web service.

4
  • 1
    When you say "without jQuery ajax", do you mean "using non-jQuery ajax"? Commented Mar 1, 2011 at 12:38
  • 2
    If you mean the "old school" way, you will find a lot of examples on google google.com/search?q=xmlhttprequest+javascript+sample :) Commented Mar 1, 2011 at 12:43
  • will you please see the question again because I edited my question? Commented Mar 1, 2011 at 12:56
  • Related post - How can I re-write this code without jQuery? Commented Jul 12, 2018 at 6:53

2 Answers 2

3

I think what you are searching for is "XMLHttpRequest". You can make an asynchronous call with it to your webserver, collect the results and parse it. You don't need a special JavaScript Framework for that. In fact, every Ajax API uses the XMLHttpRequest Object.

http://www.w3.org/TR/XMLHttpRequest/

There are many easy Examples on the web how to do that.

Sign up to request clarification or add additional context in comments.

2 Comments

can you please see the question once again.. please?
You can actually user XMLHttpRequest for that. What you have to do is: calling the API through XMLHttpRequest and parsing the result yourself. For XMLHttpRequest there is a callback called "onReadyStateChanged" where you can check if the results arrived. Then you can parse it to JSON and go on as you did.
1

If you really don't want to use ajax / XMLHttpRequest, you could make use of HTML5's WebSocket but it's not necessarily easier.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.