PDA

View Full Version : AJAX not working on sum script



Rodrigo8
12-20-2014, 08:21 PM
Hello.
I am still working on my mission of making ajax work, i am very new when it comes about javascript understanding.

So, i started by copy-pasting a shared sample (http://jsbin.com/toyojegudo/2/edit) to JSbin. The source is this tutorial :this (http://www.imaginanet.com/blog/usando-ajax-un-simple-ejemplo-con-php-y-jquery.html) (it's in spanish but i translated the code in the JSBin).

The code is composed by two files, one that asks two values and the other that sums the value and echoes it.
It uses the id of the text box to pass the values to the function doProcess. In this function, the entry values are picked into a parameter array, and we sent via AJAX the data parameter, the url and type.
At last, we have two events: beforeSend and Sucess, where we can indicate the action to do while the data is processed and after it has been processed.

This is the php of the url that is indicated on the ajax script, which is called to sum the introduced values:



<?php
$result = $_POST['boxValue1'] + $_POST['boxValue2'];
echo $result;
?>


But as you can see in the JSBin, it doesn't work and stays in "Processing, please wait...", so what is wrong in there?
Thanks!