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 9176855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:12:11+00:00 2026-06-17T17:12:11+00:00

Good Morning! I am writing a small AJAX application, using this function as a

  • 0

Good Morning!

I am writing a small AJAX application, using this function as a base, and php as serve side language.

here is the javascript code involved

var dati = {};
dati.nome = d.getElementById('nome').value;
dati.cognome = d.getElementById('cognome').value;
console.log(dati);
url = "post.php";
jsonToPost = dati;
console.log(url);

processResponse = function(responseText){
    console.log(responseText);
    d.getElementById('response').innerHTML = responseText;
}
_SU3.postAjax(url, processResponse, jsonToPost);
});

And here is my php code, just a post processor to test ajax

<?php
if(isset($_POST['nome'])){

$nome = $_POST['nome'];
$cognome = $_POST['cognome'];
$data['nome'] = $nome;
$data['cognome'] = $cognome;

$data = json_encode($data);

echo $data;
} else {
    echo "Errore!";
}
?>

The response I get from the ajaxRequest is “Errore!”, it means it’s not posting anything to the script.

Am I missing any obvious mistake? Or there is something i’m doing completely wrong?

The _SU3.ajax() function (see this for reference) is working just fine, so i’m surprised it doesn’t work

—edit to ad the firebug response—
I hope i posted the right thing

request headers:
POST /~francesco/post.php HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/2010010 Firefox/16.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://localhost/~francesco/ajax.html
Content-Length: 26
Pragma: no-cache
Cache-Control: no-cache

Screenshot
in the screen shot there are other informations.

  • 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-06-17T17:12:13+00:00Added an answer on June 17, 2026 at 5:12 pm

    As puckipedia suggested, you need to encode the object you are sending as a query string. The following method will create the parameter string based on the object passed in:

    _SU3.postAjax = function(url, callback, data) {
    
       var parameters = '';
    
       for (var p in data){
         parameters  += p + '=' + encodeURIComponent(data[p]) + '&';
       }
    
       var ajaxRequest = _SU3.getAjaxRequest(callback);
       ajaxRequest.open("POST", url, true);
       ajaxRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
       ajaxRequest.setRequestHeader("Connection", "close");
       ajaxRequest.send(parameters);
    }
    

    The function suggested in the link you provided was assuming you were passing in JSON, not a js object.

    Note: The server code you posted should interpret the data properly:

    $nome = $_POST['nome'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good Morning everyone, I am using an update command in php to update data
Good Morning, I have copied this code from somewere <script type=text/javascript> $(function() { setInterval(rotateImages(),
Good morning, I am writing a language parser, and am looking for the best
good morning programers, I have this small code which content a news control panel
Good morning, I am unsuccessfully trying to create a report using mysql/php, I would
Good morning, guys. I was just thinking about the small PHP crawler, that could
Good morning, At the startup of the application I am writing I need to
Good morning, I am working on a C# winform application that is using validation
Good morning, I am using this snippet of code to pull up a sub
Good morning, I am currently developing a java web application that exposes a web

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.