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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:00:16+00:00 2026-06-03T02:00:16+00:00

This is my code where I call the Request for Ajax, than a simple

  • 0

This is my code where I call the Request for Ajax, than a simple input button which on onClick event send some data to a function called setValue();

This is the code (JS):
//request for ajax XML

<script type='text/javascript'>
function callAjax(){
var XMLObj = false;

if(window.XMLHttpRequest)
    XMLObj = new XMLHttpRequest();
else if(window.ActiveXObject)
    XMLObj = new ActiveXObject('Microsoft.XMLHTTP');

if(!XMLObj)
    return false;

return XMLObj;

}

//var for ajaxobject handle;

var objAjax = callAjax();

function setValue(value, id, num, item){
if(objAjax){
   if(objAjax.readyState == 4 || objAjax.readyState == 0){
       objAjax.open('POST', 'addview.php', true);
       objAjax.send('value=' + val + '&id='+id+'&num='+num+'&item='+item);
   }
}
}

//input for sending value to function setValue();

<input type='button' onClick='setValue(1, 2, 3, 4)' />

//and this is where I handle the sent data via php

<?php
if(!$_POST['value'] || !$_POST['id'] || !$_POST['num'] || !$_POST['item'])
    exit();

include('config.php');

$value = mysql_real_escape_string($_POST['value']);
$id = mysql_real_escape_string($_POST['id']);
$num = mysql_real_escape_string($_POST['num']);
$item = mysql_real_escape_string($_POST['item']);

mysql_query("UPDATE `window` SET window_val = window_val + ".$value." WHERE window_id = '".$id."' AND window_num = '".$num."' AND window_item = '".$item."' ") or die(mysql_error() );
mysql_close($con);
?>

The php script is working, I tried it with sending data manually ($_GET[”]) and it’s working. Also I checked the URL with alert(‘value=’+value+’&id=’+id…) and all variables are Ok, but the database won’t be queried.

If you see, I don’t add any function for response, reply from the server. I just only want to send those data and query the data base.

Thank you !

  • 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-03T02:00:19+00:00Added an answer on June 3, 2026 at 2:00 am

    You may be missing

    objAjax.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    

    Consider improving your function names: callAjax doesn’t call Ajax, it returns a reference to the XHR object. Call it getXhr or something more like what it’s actually doing.

    If you’re ok with jQuery, just call

    function setValue(value, id, num, item){
        $.post('addview.php', 'value=' + val + '&id='+id+'&num='+num+'&item='+item);
        // or the cleaner version
        $.post('addview.php', {value: val, id: id, num: num, item:item});
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On my main page I have this jquery code which does an ajax call
I am writing jquery ajax code to call wcf service. In this case WCf
I have a simple ajax request that I am trying to call a web
From this code I can call bmwCars.CopyToDataTable() as I expected. var bmwCars = from
I make call from my app with this code (i use webview because after
I have this code inside thread and when I call terminate it terminates fast
How could I refactor this code to use only one Dir[ ] call? Dir[
I have this code: http://pastebin.com/Sd9WKZFr When i call something like rate(60, -6000, 120000) it
It was suggested that I use this line of code to call an image
how can i write this code from aspx page in code behind? <a href=skype:MySkype?call><img

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.