I have csv with 4 columns. If i select make it shows models then year. I want it to show versions at the 4th box. however nothing happens. i have changed code and it will show versions in the 3rd box and then years disappears. still nothing in 4th box.
Played around with this bit of the code which makes the above effect but cant figure out why the 4th select box dont work.
$makes_models_years_versions = array();
$uploads_folder = wp_upload_dir()['basedir'];
$file = fopen($uploads_folder.'/make_model_year_version.csv', 'r');
$firstline = true;
while (($line = fgetcsv($file)) !== FALSE) {
if ($firstline){
$firstline = false;
continue;
}
$makes_models_years_versions[$line[0]][$line[1]][$line[2]][] = $line[3];
}
COMPLETE CODE BELOW:
function ajax_cf7_populate_values() {
// read the CSV file in the $makes_models_years_versions array
$makes_models_years_versions = array();
$uploads_folder = wp_upload_dir()['basedir'];
$file = fopen($uploads_folder.'/make_model_year_version.csv', 'r');
$firstline = true;
while (($line = fgetcsv($file)) !== FALSE) {
if ($firstline){
$firstline = false;
continue;
}
$makes_models_years_versions[$line[0]][$line[1]][$line[2]][] = $line[3];
}
fclose($file);
// setup the initial array that will be returned to the the client side script as a JSON object.
$return_array = array(
'makes' => array_keys($makes_models_years_versions),
'models' => array(),
'years' => array(),
'versions' => array(),
'current_make' => false,
'current_model' => false,
'current_year' => false
);
// collect the posted values from the submitted form
$make = key_exists('make', $_POST) ? $_POST['make'] : false;
$model = key_exists('model', $_POST) ? $_POST['model'] : false;
$year = key_exists('year', $_POST) ? $_POST['year'] : false;
$version = key_exists('version', $_POST) ? $_POST['version'] : false;
// populate the $return_array with the necessary values
if ($make) {
$return_array['current_make'] = $make;
$return_array['models'] = array_keys($makes_models_years_versions[$make]);
if ($model) {
$return_array['current_model'] = $model;
$return_array['years'] = $makes_models_years_versions[$make][$model];
if ($year) {
$return_array['current_year'] = $year;
$return_array['versions'] = $makes_models_years_versions[$make][$model][$year];
if ($version) {
$return_array['current_version'] = $version;
}
}
}
}
// encode the $return_array as a JSON object and echo it
echo json_encode($return_array);
wp_die();
}
// These action hooks are needed to tell WordPress that the cf7_populate_values() function needs to be called
// if a script is POSTing the action : 'cf7_populate_values'
add_action( 'wp_ajax_cf7_populate_values', 'ajax_cf7_populate_values' );
add_action( 'wp_ajax_nopriv_cf7_populate_values', 'ajax_cf7_populate_values' );
I have list of URLs to be scraped. I get these URLs from a html table and in a controller function I put them in a foreach loop. I have two buttons Start scraping and Stop scraping.
I am running with a scraping function which is written in controller and called by an ajax function on a button click of Start scraping button.
Now my requirement is to stop the current ongoing process when I click on Stop scraping button.
I have googled a lot and tried use of Gloabal variables , sessions etc etc but all this works only after the completion of first process that comes in pending state un network.
Please help me that how can I stop the current php process when I click on Stop scraping button.
Below is the ajax call function for Start scraping
$("#get_data").click(function()
{
var values = new Array();
$.each($("input[name='case[]']:checked"), function()
{
var data = $(this).parents('tr:eq(0)');
values.push({
'weburl':$(data).find('td:eq(3)').text() ,
'id' : $(data).find('td:eq(2)').text() ,
'state':$(data).find('td:eq(6)').text()
});
});
sendmyarray(values);
});
function sendmyarray(values)
{
var location = '<?php echo base_url()?>';
var x = $.ajax({
type: "POST",
url: location+'admin/AdminController/getArrayAndScrap',
data: {myData:JSON.stringify(values)},
beforeSend: function() {
$("#stop_get_data").css("display", "block");
$("#get_data").prop('disabled', true); // disable button
},
success: function (response) {
$("#get_data").prop('disabled', false);
$("#stop_get_data").css("display", "none");
console.log(response);
if(response == 'stop')
{
alert("Process Stopped");
}
if(response == " ends")
{
alert("Process completed. Please check the status of the URLs processed!");
}
}
});
}
// BElow is the controller function //
//-- Function to get the array of selected row's url and state ; and scraping them accordingly
public function getArrayAndScrape()
{
if(isset($_POST['myData']))
{
$json = $_POST['myData'];
$myDataArray = json_decode($json,true);
foreach ($myDataArray as $url)
{
$status = $this->CommonModel->getSingleData('dtl_scrap_status','ws_detail',array('dtl_scrap_id' => $url['id']));
if( $status['dtl_scrap_status'] != 'Scrapped')
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 12); // 12 seconds
curl_setopt($ch, CURLOPT_URL, $url['weburl']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$html = curl_exec($ch);
if($html === false)
{
$this->CommonModel->addData('ws_detail' , array('dtl_scrap_status' => curl_error($ch) , 'dtl_scrap_id' => $url['id'] , 'dtl_state' => $url['state'] , 'dtl_website' => $url['weburl']));
$this->CommonModel->updateData('ws_site_scrap_detail' , array('site_last_scrap_date' => date('Y-m-d')) , array('site_id' => $url['id']));
}
else
{
$doc = new DOMDocument();
#$doc->loadHTML($html);
$nodes = $doc->getElementsByTagName('title'); // TITLE
$metas = $doc->getElementsByTagName('meta'); // Meta
$head = $doc->getElementsByTagName('h1'); // H1
if(isset($nodes->item(0)->nodeValue))
{
$title = $nodes->item(0)->nodeValue;
}
if(isset($head->item(0)->nodeValue))
{
$heading = $head->item(0)->nodeValue;
}
if(isset($metas))
{
for ($i = 0; $i < $metas->length; $i++)
{
$meta = $metas->item($i);
if($meta->getAttribute('name') == 'keywords') // Keyword
$keywords = $meta->getAttribute('content');
if($meta->getAttribute('name') != '')
{
if($meta->getAttribute('name') == 'description') // meta description
{
$description = $meta->getAttribute('content');
}
}elseif($meta->getAttribute('property') != '')
{
if($meta->getAttribute('property') == 'og:description') // meta Og:description
{
$OgDescription = $meta->getAttribute('content');
}
}
}
}
curl_close($ch);
if(isset($url['state']))
{
$addDtl['dtl_state'] = $url['state'];
}
if(isset($heading))
{
$addDtl['dtl_program_name'] = $heading;
}
if(isset($title))
{
$addDtl['dtl_program_provider'] = $title;
}
if(isset($description))
{
$addDtl['dtl_program_description'] = $description;
}elseif(isset($OgDescription))
{
$addDtl['dtl_program_description'] = $OgDescription;
}
if(isset($keywords))
{
$addDtl['dtl_program_keywords'] = $keywords;
}
if(isset($url['weburl']))
{
$addDtl['dtl_website'] = $url['weburl'];
}
if(isset($url['id']))
{
$addDtl['dtl_scrap_id'] = $url['id'];
}
$addDtl['dtl_scrap_status'] = 'Scrapped';
if($this->CommonModel->addData('ws_detail' , $addDtl))
{
$this->CommonModel->updateData('ws_site_scrap_detail' , array('site_last_scrap_date' => date('Y-m-d')) , array('site_id' => $url['id']));
}else
{
// echo "Error";exit();
}
} // End of else
} // End of status check
else
{
$this->CommonModel->updateData('ws_site_scrap_detail' , array('site_last_scrap_date' => date('Y-m-d')) , array('site_id' => $url['id']));
// echo "alscrapped";exit();
}
} // End of foreach
echo "ends";
} // End of if(isset)
}
// Something I want below scenario (AJAX CALL)//
$('#stop_get_data').click(function()
{
return false (from the function which is in running state after click event of start scraping);
});
Any help would be important for me.
Thanks
It's not possible to terminate a php script with javascript. The PHP script will continue running its loop until it finishes. PHP executes on the server side while javascript is executed on the browser. There may be a way to do something like this with sockets but I really don't know enough about them to give you any advice on how to go about it.
What you could do is run the loops on the javascript side and make individual calls to the php function for each iteration. This would allow you to stop the process with javascript whenever you like.
I am trying to reload the page after the comment is successfully submitted
Comment submitted through Ajax
After this line
// Save the comment
$state = $comment->store();
If i am trying to use location.reload(); as
// Save the comment
$state = $comment->store();
location.reload();
then its not working and comment not even submitting
Below is complete code
Can any one help - how to refresh and load page when comment is successfully submitted and stored in backend
<?php
defined('_JEXEC') or die('Unauthorized Access');
require_once(JPATH_COMPONENT . '/views/views.php');
class EasyBlogViewComments extends EasyBlogView
{
/**
* Processes comment saving
*
* #since 4.0
* #access public
* #param string
* #return
*/
public function save()
{
// Check for request forgeries
EB::checkToken();
// Test if user is really allowed to post comments
if (!$this->acl->get('allow_comment')) {
return $ajax->reject(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_POST_COMMENT'));
}
// Default values
$moderated = false;
$parentId = $this->input->get('parentId', 0, 'int');
$depth = $this->input->get('depth', 0, 'int');
$subscribe = $this->input->get('subscribe', false, 'bool');
$email = $this->input->get('email', '', 'email');
$message = $this->input->get('comment', '', 'default');
$name = $this->input->get('name', '', 'default');
$username = $this->input->get('username', '', 'default');
$password = $this->input->get('password', '', 'default');
$title = $this->input->get('title', '', 'default');
$terms = $this->input->get('terms', false, 'bool');
$blogId = $this->input->get('blogId', 0, 'int');
$isCB = $this->input->get('iscb', 0, 'int');
// If there is no name, and the current user is logged in, use their name instead
if (!$name && $this->my->id) {
$user = EB::user($this->my->id);
$name = $user->getName();
}
// Validate the email
$data = array('post_id' => $blogId, 'comment' => $message, 'title' => $title, 'email' => $email, 'name' => $name, 'username' => $username, 'terms' => $terms);
// Load up comment table
$comment = EB::table('Comment');
$state = $comment->validatePost($data);
if (!$state) {
return $this->ajax->reject($comment->getError());
}
// Bind the data on the comment table now
$comment->bindPost($data);
// Check for spams
if ($comment->isSpam()) {
return $this->ajax->reject(JText::_('COM_EASYBLOG_SPAM_DETECTED_IN_COMMENT'));
}
$captchaResponse = EB::captcha()->verify();
// Perform captcha verification
if (isset($captchaResponse->success) && $captchaResponse->success == false) {
return $this->ajax->reject($captchaResponse->errorCodes);
}
// Get current date
$date = EB::date();
// Set other attributes for the comment
$comment->created = $date->toSql();
$comment->modified = $date->toSql();
$comment->published = true;
$comment->parent_id = $parentId;
$comment->created_by = $this->my->id;
// Process user registrations via comment
$register = $this->input->get('register', '', 'bool');
if ($register && $this->my->guest) {
if (empty($password) || empty($username) || empty($email)) {
return $this->ajax->reject('COM_EASYBLOG_COMMENT_REGISTRATION_FIELD_EMPTY');
}
$userModel = EB::model('Users');
$id = $userModel->createUser($username, $email, $name, $password);
if (!is_numeric($id)) {
return $this->ajax->reject($id);
}
$comment->created_by = $id;
}
$totalComments = $this->input->get('totalComment', 0, 'int');
// Determines if comment moderation is enabled
if ($this->config->get('comment_moderatecomment') == 1 || ($this->my->guest && $this->config->get('comment_moderateguestcomment'))) {
$comment->published = EBLOG_COMMENT_STATUS_MODERATED;
}
// Load up the blog table
$blog = EB::table('Blog');
$blog->load($comment->post_id);
// If moderation for author is disabled, ensure that the comment is also published automatically.
if ((!$this->config->get('comment_moderateauthorcomment') && $blog->created_by == $this->my->id) || EB::isSiteAdmin()) {
$comment->published = true;
}
// Update the ordering of the comment before storing
$comment->updateOrdering();
// Save the comment
$state = $comment->store();
if (!$state) {
return $this->ajax->reject($comment->getError());
}
$resultMessage = JText::_('COM_EASYBLOG_COMMENTS_POSTED_SUCCESS');
$resultState = 'success';
// If user registered as well, display a proper message
if ($register) {
$resultMessage = JText::_('COM_EASYBLOG_COMMENTS_SUCCESS_AND_REGISTERED');
}
if ($comment->isModerated()) {
$resultMessage = JText::_('COM_EASYBLOG_COMMENT_POSTED_UNDER_MODERATION');
$resultState = 'info';
}
// Process comment subscription
if ($subscribe && $this->config->get('main_subscription') && $blog->subscription) {
$subscribeModel = EB::model('Subscription');
$subscribeModel->subscribe('blog', $blog->id, $email, $name, $this->my->id);
}
// Process comment notifications
$comment->processEmails($comment->isModerated(), $blog);
// Set the comment depth
$comment->depth = $this->input->get('depth', 0, 'int');
// Update the sent flag
$comment->updateSent();
// Format the comments
$result = EB::comment()->format(array($comment));
$comment = $result[0];
$language = JFactory::getLanguage();
$rtl = $language->isRTL();
$theme = EB::template();
$theme->set('comment', $comment);
$theme->set('rtl', $rtl);
$output = '';
if ($isCB) {
// if the is saving from CB plugin, then we need to display the output using different template.
$output = $theme->output('site/comments/cb.item');
} else {
$output = $theme->output('site/comments/default.item');
}
return $this->ajax->resolve($output, $resultMessage, $resultState);
}
public function reloadCaptcha()
{
$ajax = EB::ajax();
// Get the previous captcha id.
$id = $this->input->get('previousId', 0, 'int');
$captcha = EB::table('Captcha');
$state = $captcha->load($id);
if ($state) {
$captcha->delete();
}
// Generate a new captcha
$captcha = EB::table('Captcha');
$captcha->created = EB::date()->toSql();
$captcha->store();
$image = EB::_('index.php?option=com_easyblog&task=captcha.generate&tmpl=component&no_html=1&id=' . $captcha->id, false);
return $ajax->resolve($image, $captcha->id);
}
2nd File
EasyBlog.module('comments/form', function($) {
var module = this;
EasyBlog.require()
.script('comments/captcha', 'comments/list')
.library('markitup')
.done(function($) {
EasyBlog.Controller('Comments.Form', {
defaultOptions: {
"{formWrapper}": "[data-comment-form-wrapper]",
"{form}": "[data-comment-form]",
"{title}": "[data-comment-title]",
"{name}": "[data-comment-name]",
"{username}": "[data-comment-username]",
"{password}": "[data-comment-password]",
"{email}": "[data-comment-email]",
"{register}": "[data-comment-register]",
"{website}": "[data-comment-website]",
"{counter}": "[data-comment-counter]",
"{subscribe}" : "[data-comment-subscribe]",
"{terms}": "[data-comment-terms]",
"{tncLink}": "[data-comment-tnc]",
"{parentId}" : "[data-comment-parent-id]",
"{commentDepth}": "[data-comment-depth]",
"{blogId}" : "[data-comment-blog-id]",
"{depth}": "[data-comment-depth]",
"{notice}": "[data-comment-notice]",
"{editor}": "[data-comment-editor]",
"{submit}": "[data-comment-submit]",
"{formToken}": "[data-comment-token]",
"{recaptcha}": "[data-recaptcha-item]"
}
}, function(self, opts, base) {
return {
init: function() {
self.initEditor();
self.list = self.addPlugin('list');
// If recaptcha is enabled, we should skip the normal captcha
var recaptcha = self.recaptcha.inside(self.element).length;
if (recaptcha < 1) {
self.captcha = self.addPlugin('captcha');
}
},
initEditor: function() {
if (self.editor().data('comment-bbcode') == 1) {
self.editor().markItUp(window.EasyBlogBBCodeSettings);
}
},
setNotice: function(message, type) {
var className = '';
if (type == 'error') {
className = 'alert-danger';
}
if (type == 'success') {
className = 'alert-success';
}
if (type == 'info') {
className = 'alert-info';
}
self.notice()
.removeClass('hide')
.addClass('alert ' + className)
.html(message);
},
resetForm: function() {
// If the comment form has a parent id, we need to reposition the comment form back.
var parentId = self.parentId().val();
if (parentId != 0) {
self.form().appendTo(self.formWrapper());
}
// Reset the form
self.username().val('');
self.password().val('');
self.subscribe().attr('checked', false);
self.editor().val('');
self.website().val('');
self.name().val('');
self.depth().val(0);
self.parentId().val(0);
self.trigger('resetForm');
// Determine if recaptcha is available
var recaptcha = self.recaptcha.inside(self.element);
// Get recaptcha's response
if (recaptcha.length > 0) {
grecaptcha.reset();
}
},
resetNotice: function() {
self.notice()
.removeClass('info error')
.html('');
},
"{self} replyComment": function(el, event, commentItem, commentId, commentDepth) {
// Hide notices in the reply form
self.notice().addClass('hide');
// When user tries to reply to an existing comment, move the form next to the level of the comment item
commentItem.after(self.form());
self.depth().val(commentDepth);
// Set the new parent id to the comment's id
self.parentId().val(commentId);
},
"{self} cancelReply": function(el, event, commentItem, commentId) {
// Set the parent id to 0
self.parentId().val(0);
// Reset the comment depth back to 0
self.depth().val(0);
// Relocate the form back to it's origin
self.formWrapper().html(self.form());
},
"{self} commentAdded": function()
{
// Increment the counter
var count = self.counter().html();
count = parseInt(count) + 1;
self.counter().html(count.toString());
self.resetForm();
},
getValues: function() {
var data = {
title: self.title().val(),
name: self.name().val(),
email: self.email().val(),
username: self.username().val(),
password: self.password().val(),
website: self.website().val(),
subscribe: self.subscribe().is(':checked') ? 1 : 0,
register: self.register().is(':checked') ? 1 : 0,
comment: self.editor().val(),
terms: self.terms().is(':checked') ? 1 : 0,
depth: self.depth().val(),
parentId: self.parentId().val(),
blogId: self.blogId().val()
};
// token
// data[self.formToken().attr('name')] = 1;
// Determine if recaptcha is available
var recaptcha = self.recaptcha.inside(self.element);
// Get recaptcha's response
if (recaptcha.length > 0) {
data.recaptcha = grecaptcha.getResponse();
}
self.trigger('submitComment', [data]);
return data;
},
"{tncLink} click": function() {
EasyBlog.dialog({
content: EasyBlog.ajax('site/views/comments/terms')
})
},
"{submit} click" : function(el, event) {
event.preventDefault();
// Reset notices
self.resetNotice();
// Add loading indicator on the button
$(el).attr('disabled', true);
var tmp = $(el).html();
$(el).html('<i class="fa fa-repeat fa-spin"></i>');
// Get the form values
var data = self.getValues();
// Perform an ajax call to submit the comment
EasyBlog.ajax('site/views/comments/save', data)
.done(function(output, message, state) {
self.setNotice(message, state);
self.trigger('commentAdded',[output, data]);
})
.fail(function(message) {
self.setNotice(message, 'error');
})
.always(function(){
$(el).removeAttr('disabled');
$(el).html(tmp);
self.trigger('reloadCaptcha');
});
return false;
}
}
});
module.resolve();
});
});
I would hazard a guess that the place to add the location.reload() would be within this snippet:
"{self} commentAdded": function()
{
// Increment the counter
var count = self.counter().html();
count = parseInt(count) + 1;
self.counter().html(count.toString());
self.resetForm();
},
So perhaps like:
"{self} commentAdded": function()
{
// Increment the counter
var count = self.counter().html();
count = parseInt(count) + 1;
self.counter().html(count.toString());
self.resetForm();
/* reload */
location.reload();
},
Or, you could add it to the .done method within EasyBlog.ajax .... pretty much the same thing I think by looking at the code though
i was doing long polling , but it can see in my network chrome my long polling in status pending that means is waiting for new data and changes the database , but when I try to insert one item to my database then , but when I try to insert one value show keep that long polling in real time i cant see real time updatings .. how can I fix it?
pusher controller codeigiter
public function pusher() {
header('Content-Type: application/json');
$user_id = $this->session->log['id'];
set_time_limit(0);
while (true) {
$firstCall = false;
if (isset($_GET['timestamp'])) {
$last_ajax_call = $_GET['timestamp'];
} else {
$last_ajax_call = time();
$firstCall = true;
}
clearstatcache();
$notificationsCount = $this->notification->checkForNotifications($last_ajax_call, $user_id);
$newData = (int) $notificationsCount > 0 ? true : false;
$notifications = [];
if ($newData) {
$dataSet = $this->notification->getNotifications($user_id, $last_ajax_call);
foreach($dataSet as $data) {
$notifications[] = $data;
$finalNotificationTime = $data['timestamp'];
}
$result = array('notifications' => $notifications, 'timestamp' => $finalNotificationTime);
$json = json_encode($result);
echo $json;
break;
} else {
if ($firstCall) {
$dataSet = $this->notification->getUnreadNotifications($user_id);
foreach($dataSet as $data) {
$notifications[] = $data;
}
$result = array('notifications' => $notifications, 'timestamp' => $last_ajax_call);
$json = json_encode($result);
echo $json;
break;
}
sleep(1);
session_write_close();
continue;
}
}
exit();
}
ajax
function check_notifications(timestamp) {
var queryString = {
'timestamp': timestamp
};
$.ajax({
type: 'GET',
url: URL_GET_NOTIFICATION,
data: queryString,
success: function (data) {
// put result data into "obj"
for (var i in data.notifications) {
notify(data.notifications[i].message, data.notifications[i].type, data.notifications[i].timestamp);
}
check_notifications(data.timestamp);
}
});
}
check_notifications();
I am wanting away to list all my files and folders in a JSON but I need to be able to call the files using jQuery
Basically what I have is the following
public function listproductimagedirectory($rootPath) {
$pathStack = array($rootPath);
$contentsRoot = array();
$contents = &$contentsRoot;
while ($path = array_pop($pathStack)) {
$contents[basename($path)] = array();
$contents = &$contents[basename($path)];
foreach (scandir($path) as $filename) {
if ('.' != substr($filename, 0, 1)) {
$newPath = $path.'/'.$filename;
if (is_dir($newPath)) {
array_push($pathStack, $newPath);
$contents[basename($newPath)] = array();
} else {
$contents[basename($filename)] = $newPath;
}
}
}
}
return $contentsRoot[basename($rootPath)];
}
which outputs
{"giftcard":{"31791_319x242_0.jpg":"..\/products\/giftcard\/31791_319x242_0.jpg","7520921_0_9999_lge_v1_m56577569834701600.jpg":"..\/products\/giftcard\/7520921_0_9999_lge_v1_m56577569834701600.jpg","AMF.jpg":"..\/products\/giftcard\/AMF.jpg","accor.jpg":"..\/products\/giftcard\/accor.jpg","accorhotel.png":"..\/products\/giftcard\/accorhotel.png","cellarmasters.png":"..\/products\/giftcard\/cellarmasters.png","dusk.png":"..\/products\/giftcard\/dusk.png","giftca_100ath_lrg.png":"..\/products\/giftcard\/giftca_100ath_lrg.png","giftca_100goo_lrg.png":"..\/products\/giftcard\/giftca_100goo_lrg.png","giftca_100sun_lrg.png":"..\/products\/giftcard\/giftca_100sun_lrg.png","giftca_20itu_lrg.png":"..\/products\/giftcard\/giftca_20itu_lrg.png","giftca_25abc_lrg.png":"..\/products\/giftcard\/giftca_25abc_lrg.png","giftca_25jay_lrg.png":"..\/products\/giftcard\/giftca_25jay_lrg.png","giftca_30bra_lrg.png":"..\/products\/giftcard\/giftca_30bra_lrg.png","giftca_30div_lrg.png":"..\/products\/giftcard\/giftca_30div_lrg.png","giftca_40ebg_lrg.png":"..\/products\/giftcard\/giftca_40ebg_lrg.png","giftca_50col_lrg.png":"..\/products\/giftcard\/giftca_50col_lrg.png","giftca_50cou_lrg.png":"..\/products\/giftcard\/giftca_50cou_lrg.png","giftca_50dot_lrg.png":"..\/products\/giftcard\/giftca_50dot_lrg.png","giftca_50dym_lrg.png":"..\/products\/giftcard\/giftca_50dym_lrg.png","giftca_50hoy_lrg.png":"..\/products\/giftcard\/giftca_50hoy_lrg.png","giftca_50itu_lrg.png":"..\/products\/giftcard\/giftca_50itu_lrg.png","giftca_50jac_lrg.png":"..\/products\/giftcard\/giftca_50jac_lrg.png","giftca_50jea_lrg.png":"..\/products\/giftcard\/giftca_50jea_lrg.png","giftca_50pet_lrg.png":"..\/products\/giftcard\/giftca_50pet_lrg.png","giftca_50por_lrg.png":"..\/products\/giftcard\/giftca_50por_lrg.png","giftca_50reb_lrg.png":"..\/products\/giftcard\/giftca_50reb_lrg.png","giftca_50san_lrg.png":"..\/products\/giftcard\/giftca_50san_lrg.png","isubscribe.jpg":"..\/products\/giftcard\/isubscribe.jpg","isubscribe.png":"..\/products\/giftcard\/isubscribe.png","peteralexander.png":"..\/products\/giftcard\/peteralexander.png","rydges hotel.png":"..\/products\/giftcard\/rydges hotel.png","smiggle.png":"..\/products\/giftcard\/smiggle.png","sportsgirl.png":"..\/products\/giftcard\/sportsgirl.png","sussan.png":"..\/products\/giftcard\/sussan.png","wiggles.png":"..\/products\/giftcard\/wiggles.png"}}
What I see and I could be wrong but there is nothing the allows me to tell the ID of the array for e.g I am use to calling a JSON by using the each function and using something like this
obj.title that would tell me that its the title of the json row.
put your objects in an array... so you would have..
var myobject = { giftcard: [ {filename: "image1.png", path: "path"}, {filename: "image2.png", path: "path""}, {filename: "image3.png", path: "path"} etc...]}
then you can:
$.each(myobject.giftcard, function(index, image) {
image.filename
image.path
});