Jump to content

AJAX JSON object help


ron8000

Recommended Posts

Hello everyone,

 

    I'm creating an AJAX Select Box filter for a project, I am using Prototype (latest ver)

 

My goal is when a user makes a selection the JS will send a request to a script and send

 

    1. A formated list of all the select fields

    2. The name of the field that was changed.

    3. The value of the field that was changed.

 

I've got the php script done, and at the moment to output either.

 

   1. name=value&name=value

   2. JSON formated object

 

My issue lies in pulling the vaues by a JS Var.

function filterRequestReturn(requestResponse)
{
var info = requestResponse.responseText;

            /* For JSON */
          	var ajax_return = evalJSON(true)

           /* For the name=value&name=value
var ajax_return = info.split('&'); */

var filter_fields = jsFilter.split("-");

filter_fields = filter_fields.without('');

for(var i=0;i<filter_fields.length;i++)
{
     alert(ajax_return.filter_fields[i]);
}

var oXY2=$('myTestDiv');
oXY2.style.zIndex = '140';
oXY2.innerHTML=ajax_return.total;
oXY2.show();
}

 

The line alert(ajax_return.filter_fields); will not work... is there a way to pull values form a JSON object using a var?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.