Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

I need to call my REST API that is written in PHP from a javascript script. A similar situation I can point to is the jquery ui autocomplete plugin. When you specify an external php script for the source attribute, it reads the output from the php script, and uses that as the autocomplete options.

share|improve this question
3  
you can use $.ajax, $.post, $.get – Saleh Aug 6 '12 at 21:29

3 Answers 3

up vote 3 down vote accepted

you could use the jQuery ajax function:

http://api.jquery.com/jQuery.ajax/

share|improve this answer
    
Thanks, and can anyone explain why I got so downvoted, so I can format my question better next time? I did do several google searches before asking this question, but was unsuccessful. – prashn64 Aug 6 '12 at 21:36

AJAX. That is all.

If you have any more specific issues, feel free to ask.

share|improve this answer

You can use an AJAX request (if I understood the question) If your API is written in myapi.php, you can:

var word = "The Word";
$.ajax({
    url: "myapi.php?action=searchfor&word="+word,
    success: function(data){
        alert(data);
    }
});

...assuming you're using jQuery, of course :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.