Passing Variables Through Jquery AJAX?

Apr 18, 2011

I am trying to learn the Jquery AJAX function but am struggling to work out how to pass PHP variables into my main document.This is what I currently have:

var refreshId = setInterval(function() {

View 5 Replies


AJAX And JQuery / Variables Not Passing?

Trying to do something very simple: Pass 2 text variables to a php script and insert them into a MySQL db. For some reason however I can't get the variables to pass (so I just get empty records in my DB).

function ajaxCall(){
type: "GET",
cache: false,

Anyone willing to take a quick look at it and point out my -probably obvious- mistake? It's been driving me nuts for over a day!

View 4 Replies

JQuery AJAX Not Passing Values To AJAX Call

the problem is that jQuery does not pass value to a certain PHP file in order to run a DELETE query and remove the content you requested to be removed from database. The script works great with one other file which requests the information from MySQL and loads it via AJAX call to a php file. The problem might be in this script the actual AJAX

$(".removeNote").live('click',function() {
$("#qpbox-loader").html("<img src='' />");
var xhr = $.ajax({
type: "GET",
url: "_class/delete_notes.php",

View 2 Replies

[JQUERY/PHP] Send And Use POST Variables Using JQuery.ajax()?

Is it possible to access $_POST variables without appending all the form elements into the data attribute?Ajax call:

type: "POST",

View 2 Replies

Passing JavaScript Array To PHP Through JQuery $.ajax?

I want to manipulate a javascript array in PHP. Is it possible to do something like this?

type: "POST",
url: "tourFinderFunctions.php",[code]...

Activities is a single dimensional array like:

var activities = ['Location Zero', 'Location One', 'Location Two'];

The script does not complete when I try this..

View 4 Replies

Passing Data To An Ajax Request Jquery?

i have this problem, where the data im trying to send to the ajax request is not passing! i.e.

var user=<?php echo $user?>;
type: "POST",
url: "actions/sub.php",


View 1 Replies

Passing Specific Data From A Table By Jquery Ajax?

the application simply isdynamic page generate html code with some data within table cells by receiving parametersi could get these pure data by jquerybut i find trouble sending it by ajax to another page(the basic page) to display it in another format

View 1 Replies

Passing Array Into A Javascript Code Jquery/ajax?

At the moment i have this piece of javascript code:

//Display custom confirm box and delete multiple message
$(document).ready( function()
$(".delete_button-multiple").click( function()
//Get message id as variable
var id = $(this).attr("id");
var dataString = 'id='+ id ;
var parent = $(this).parent();


The difficulty i'm having is changing the working code above to incorporate the multiple selection, and deletion, of selected mails.

View 2 Replies

Use Related Select Through Jquery Ajax And Also Through Passing Parameters?

I am using the related select plugin for jquery mentioned url selects code: url.It works ok I have no problem with it. Lets say i use it on url page. Now what i want to do is to somehow prepopulate the selects when i open some link in following format.


the passed parameter are the selected options for the menus. The StateID is dependant on CountryId selection and the former is populated after selection on countryID Meaning that I dont have to do selection for menus if i have provide PHP parameters

View 2 Replies

Javascript - Passing Array Value From Jquery Ajax To Function Call?

I have a 10 checkboxes, when i want to delete the appropriate record I use to select one or more checkbox. All the checkbox nams are array. I'm properly getting the values from the html page to jquery function. After that i pushed all the checked boxes into the array created in the jQuery function. But i'm not able to sent the values from this jquery function to the ajax php function. May be the way i'm trying will be wrong. Please check out my code below.

function BulkDelete()// jQuery Function
var Selected = new Array();


I'm not getting any error. But the same time it's always returning 1.

View 1 Replies

Passing Jquery Values To Variables?

i have a form in another form..


the form2 is submited automatically, and has only one field of fileupload, and is auto processing file upload with jquery ajax...!!

it works fine for me but when i pass the response filename of form2 to form1 <input> field it shows me fine........but when i submit form1 the <input> field which contains the form2 response value it says empty.

View 4 Replies

Passing Variables To A JQuery Modal Window

my goal is to have a modal popup with php variables passed to it...

for example - EITHER load a popup php page, view_details.php?id=1


pass the php variables directly to the modal for the specified id. I currently have jqueryUI installed, but am open to using any module.

View 3 Replies

Javascript - JQuery Passing Variables To MySQL?

The below code works as far as I can tell except for the var tid and var open section. They are being submitted from an image href:

$("#chngeHref").click(function() {
var tid = $('tid').attr('value'); // VARIABLES DONT WORK
var open = $('open').attr('value'); // VARIABLES DONT WORK


HTML code this is coming from:

<a href="#" id="chngeHref" /><img src="<?php echo "image.php?url=" . $row[2]; ?>?tid=<?php echo $row[0]; ?>&open=<?php echo $row[1]; ?>" id="chnge" /></a>

Which works perfectly fine (output: image.php?url=image.jpg?tid=1&open=1). The issue is I don't think I have the var tid/open set up right to actually read the variables and pass them onto my mysql page (where I need to values to update the db). I have tried:

var tid = $('tid').attr('value');
var tid = $('.tid').attr('value');
var tid = $('#tid').attr('value');

I just don't know enough to make it work.

View 2 Replies

Passing Variables Between Modules Loaded With JQuery?

I'm using jQuery to load a PHP module, in "deferred" mode, however the jQuery loaded module cannot access variables of the "main" PHP module. It looks like it can't access session variables too.

This is the code used to load the "deferred" page:

<script type="text/javascript">
jQuery("#sidebarfeat").one('inview', function(event, isInView, visiblePartX, visiblePartY) {
if (isInView) {


The code above uses jQuery inview plugin, however the problem lies into the PHP environment, it looks like the 2 PHP modules are running in "separated" environments....

View 3 Replies

Get More Variables Instead Of String In Jquery $ajax?

I have this script:

url: 'submit_to_db.php',
type: 'POST',
data: 'name=' + name + '&email=' + email + '&comments=' + comments,


Then in my php file, after insert to database, I echo "comment updated", then append to my container and slowly fade away. In the meantime, I want to insert the new comment into the container as well. So I tried echo "comment updated!&com=".$comment; but it was returned as string rather than 2 variables.

i am getting undefined in my php file,

$comment = $_POST['comment']

View 2 Replies

Access Variables When Calling Ajax In JQuery?

I am attempting to create a simple comment reply to posts on a forum using the AJAX function in jQuery. The code is as follows:

$.ajax({type:"POST", url:"./pages/submit.php", data:"comment="+ textarea +"& thread="+ currentId, cache:false, timeout:10000,
success: function(msg) {
// Request has been successfully submitted


This call works on all other pages I use on the site, but I cannot access any of my variables via the AJAX function. I've tested everything more than once and I can echo back whatever, but anytime I try to access my other PHP variables or functions I just get this error:

Failed [object XMLHttpRequest]

Why am I unable to access my other functions/variables? I must submit the data sent into a database inside submit.php using my already made $mySQL variable, for example. Again these functions/variables can be accessed anywhere else except when I call it using this AJAX function. After hours of Googling I'm just spent. Can anyone shed some light on this for me?

View 2 Replies

Retrieve HTML And Variables With JQuery/Ajax ?

I have an HTML form which uses selections from a drop-down list to populate a mySQL table, but with jQuery / AJAX calling an external php file to update the display of entered lines below the original form.The purpose of the form is an order entry system, and as such works: select an item, see it added to the list. The problem that I have is that as well as having the entered items displayed, I want to show the total order value updating. I thought that I would be able to use a PHP session variable, but that doesn't seem to work unless the original page is refreshed.Therefore, my question is: is there a way to get session variables (or any other sort of variable) back from my external php file as well as the HTML that I am appending to the displayed page?

type: "POST",
url: "ajaxInsertOrde

View 4 Replies

Passing Javascript Form Variables Into JQuery Function Not Working?

I am trying to pass some JavaScript variables that I have assigned to form variables into a query string used by a jQuery plug in called fancybox. If I hard code in the string that I want lightbox works great, however I need it to pass some form values in there to make it work as desire.

<script type="text/javascript">
var item = document.itemFinder.item;
var zip =;


View 1 Replies

Load Multiple Variables Via JQuery AJAX Request

i have this jQuery script using ajax to load a response from a php file, but i want to do is to load maybe two variables from the php script rather than the whole page.

$(document).ready(function() {
cache: false
var refreshId = setInterval(function() {

So what i want is to be able to say load variable1 from the php page into object_area, then load variable2 into object_area2 if that makes sense?

View 1 Replies

Use JQuery AJAX $.post To Store PHP $_SESSION Variables?

I have a paginated gallery with checkboxes beneath each image and I need to store the checkbox values in session variables if a user moves between the pages, so when they submit the form at any time it will include all checked values across all pages. I'm using this jQuery code:

$(document).ready(function() {
$(".gal-nav").click(function() {
$.post("form-data-holder.php", $("#gallery-form").serialize());

and the form-data-holder.php file says this:


1) How do I get the checkbox values out of the serialize() function? I think there's more I have to do with something like value[] to get that array out, and then I guess store each one as a separate session variable -- unless I can store an array as a $_SESSION variable?

2) Before I even mess with any of that, I added that line $_SESSION['saved'] = "true"; to the php script and then I echo the $_SESSION keys and values on my gallery page to see if the AJAX request is even working. It's not. That $_SESSION['saved'] isn't added to the list of echoed $_SESSION variables when I return to the page.

View 2 Replies

Jquery - Send Variables To A Controller Action Via GET In AJAX

I want to send a variable "itemId" via GET to a controller action through AJAX. In the Controller Action, I should be able to retrieve the value using $_GET["itemId"];

Can I send the querystring with "data" tag instead of appending it to the "url"?

I have the following code:

type: 'GET',
url: "/controller/controlleraction",
data: itemId,


View 4 Replies

Javascript - Use JQuery's .ajax() Function Retrieve Variables From A Script?

-I have read about json being a simple way but also read its a bad practice to use eval() once the data is retrieved. So I don't know how so use the data returned.

-The only way i've been able to retrieve data from php scripts is if I echo the results already formatted (which is not very convenient). Also if there is a redirect in the php script the whole redirected pages html gets passed back to javascript. recommend a way to send variables or arrays back to javascript from php?

View 6 Replies

Jquery Ajax Load Only Works With Single Word Variables?

Within my PHP file, I'm passing some variables around from an input box into a link, which loads a page via jQuery's ajax load function with that variable in its URL.

This whole system works perfectly, but it only works with single-word variables. Anytime there is a space involved, my Ajax call breaks. I'm assuming this is an encoding issue, but I have some doubts there as well. Basically, it boils down to this line of code in my PHP file which is causing a ruckus.

Is it possible to find out if this is formatted correctly, or why this would break with multi-world queries? The "Keyword" variable has jQuery's trim function applied to it.

echo $("#addminimal").load("/addmnml?topic='.$_GET['keyword'].'") ;

View 3 Replies

Codeiniter - Posting Form Variables And Retrieving Through JQuery AJAX

I need to post a variable and get result in Codeigniter using Ajax jQuery. Although my db has content, the code is still returning me empty array. - array(0) {}. The problem is that the variable is not getting posted from the form. Here is my code:

<form id = "myform1" onsubmit="return false">
<select name="field_country">
<option value="0">Argentina</option>
<option value="1">Chile</option>

View 2 Replies

JQuery - Pass Variables To Script Via AJAX Call And Then Display File

I'm trying to generate Outlook event files for my events, doing so on the fly as and when someone requests it by pressing a link on the page.

Here's what i've got so far, but I can't find out how to get the browser to download the content which is returned.

I know how I could do this if I sent everything via _GET, but I'd prefer to do it via _POST, hence I'm going down this route..

HTML / Javascript

$(function() {
$(".button").click(function() {
// validate and process form
// first hide any error messages


View 1 Replies

Javascript - Calling Script With Ajax And JQuery / Send It POST, Not GET So The User Can't See The Variables In Address Bar?

Right now I have this:

echo "<a href='misc/removeWallComment.php?id=" .
$displayWall['id'] . "&uID" . $displayWall['uID'] . "&BuID" .
$displayWall['BuID'] . "' title='ta bort inlägg'>
<span class='removeWallComment'></span> </a>";

Its an icon with a link that removes the comment when you click.

Now, it goes to misc/removeWallComment.php and echo out "comment removed". But I would like to integrate it with my current site, so you don't go to another page to delete the commehnt. With this I thought of using an ajax call to removeWallComment.php.

Now as you see on the link it requires three variables, id, uID and BuID, and I want to send it POST, not GET so the user can't see the variables in address bar. On success it should just alert ok.

How can I do this?

View 2 Replies

Copyrights 2005-15, All rights reserved