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
https://forums.phpfreaks.com/topic/113505-ajax-json-object-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.