Post and Retrieve the same time using ajx

Post and Retrieve the same time using ajx

Hi,

I am using below code to post signup data using ajax but at the same time to get the registered data using json so it can be used by the browser.

  1. $.ajax({
  2.     type: "POST",
  3.     url: 'https://www.mydomain.com/ws/signup.php',
  4.     data: formData,
  5.     processData: false,
  6.     contentType: false,
  7. }).done(function () {
  8.     viewModel.loadPanelVisible(false);

  9.     customer.insert({
  10.         customer_id: data.Customer[0].customer_id,
  11.         first_name: data.Customer[0].first_name,
  12.         last_name: data.Customer[0].last_name,
  13.         mobile: data.Customer[0].mobile,
  14.         email_address: data.Customer[0].email_address,
  15.         loggedon: false
  16.     })

and in my php after finishing the signup I am doing this:

  1. $jsonData = '{ "Customer" :[';

  2. $jsonData .= '{"customer_id":"' . $customer_id;
  3. $jsonData .= '","customer_guid":"' . $customer_guid;
  4. $jsonData .= '","title":"' . $title;
  5. $jsonData .= '","first_name":"' . $first_name;
  6. $jsonData .= '","last_name":"' . $last_name;
  7. $jsonData .= '","gender":"' . $gender;
  8. $jsonData .= '","nationality":"' . $nationality;
  9. $jsonData .= '","birthday":"' . $birthday;
  10. $jsonData .= '","email_address":"' . $email_address;
  11. $jsonData .= '","mobile":"' . $mobile;
  12. $jsonData .= '"},';

  13. $jsonData = chop($jsonData, ",");
  14. $jsonData .= ']}';

  15. echo $jsonData;

How can I do this please.



Thanks,