Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7695591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:34:44+00:00 2026-05-31T21:34:44+00:00

I am intending to create a small api, that will do some php functions,

  • 0

I am intending to create a small api, that will do some php functions, but can be implemented by js only.
I want to create a similar solution to the facebook sdk.
So I created a php file named rest.php
and a js file nammed conjs.js now I need to perform an ajax request from the conjs.js file, but I get an undefined when trying to request an ajax request.
1) How should I build this?
2) What am I doing wrong?

rest.php

<?php 

echo "Hello from ".$_GET['name'];
?>

conjs.js –> included on the html page of client (similar to

connect.facebook.net/en_US/all.js off facebook)

function getDev(){
$.ajax({
    url: 'http://mydomain/rest.php',
    type: 'GET',
    data: 'Name=John', // or $('#myform').serializeArray()
    success: function(data) { return('Get completed '+data); }
});
}

Client smaple html page: -not on domain-

<html><head> <script src="http://mydomain/conjs.js"></script></head><body>
<script>
alert(getDev());
</script>
</body></html>

Thanks in advance 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:34:45+00:00Added an answer on May 31, 2026 at 9:34 pm

    You need to use a callback due to ajax’s asynchronous nature.

    A callback is a function that is passed as an argument to another function which executes the callback at an interesting point. In the case below, it’s in the success block of the ajax response which is considered as interesting.

    Try this:

    function getDev(callback){
    $.ajax({
        url: 'http://mydomain.com/rest/rest.php',
        type: 'GET',
        data: 'Name=John', // or $('#myform').serializeArray()
        success: function(data) { 
            callback('Get completed '+data); 
        }
    });
    }
    

    Later when calling:

    <script type="text/javascript">
    getDev(function (response) {
        alert(response);
    });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a multilne variable that will be split over several-lines, indenting
I'm intending to create a flash app that pulls images from facebook and displays
I want to create an instance of an IronPython class from C#, but my
I am developing a system that will have a database backend. I am intending
It seems that if I want to create a very basic Cocoa application with
I am intending to use SQLite 3 with PHP 5. I found this: http://packages.debian.org/etch/web/php5-sqlite3
I am still developing this function, but here is what I am intending it
I'm starting to do a small amount of development within my company. I'm intending
I was intending to create a splash screen like the one sported by Visual
This is a loop in a function intending to create elements <li> and give

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.