jquery - Differences between JSON response with Safari and Safari Mobile -
i noticing strange behavior between different browsers json response. browser i'm having issue safari mobile, ios simulator.
i'm using codeigniter , returning partial view. in browsers (except safari mobile) json response returns following:
response.html = "<li>...</li> <li>...</li> <li>...</li> <li>...</li> <li>...</li> <li>...</li>" this want - expect 6 list items , inject page. in safari mobile reason response contains array of 5 objects - these objects contain of data should used populate partial view:
response: array[5] 0: object 1: object 2: object 3: object 4: object length: 5 the ajax call looks like:
function getrandommovies () { $.mobile.showpageloadingmsg("a", "fetching random movies"); $.ajax({ url: "random/get_random_movies", type: "post", datatype: "json", contenttype: "application/json", cache: false, success: function (response) { $('#random-gallery').html(response.html); initphotoswipe(); $.mobile.hidepageloadingmsg(); }, error: function(xmlhttprequest, textstatus, errorthrown) { alert("status: " + textstatus); alert("error: " + errorthrown); } }); } in controller method ajax call have following should, , in browsers, return html.
public function get_random_movies(){ $movies = $this->random_model->get_random_movies(); $data['results'] = $movies; $response['html'] = $this->load->view('partials/_random_movie_multiple', $data, true); echo json_encode($response); } you'll have forgive me pasting these code blocks believe necessary debug issue. on appreciated, i've spent huge amount of time on trying debug problem, no avail.
edit 1:
_random_movie_multiple.php
foreach ($results $result) { echo '<li><a data-ajax="false" rel="external" data-href="search/movie/'.url_title($result->title, "-", true).'/'.$result->id.'" data-caption="'.$result->title.' ('.$result->release_year.')" href="'.$result->img284.'"><img src="'.$result->img88.'"/></a></li>'; }
Comments
Post a Comment