Reputation: 871
I have a ajax function as below
<script type="text/javascript">
$(document).ready(function () {
var timer, delay =600000; //5 minutes counted in milliseconds.
timer = setInterval(function(){
$.ajax({
type: 'POST',
url: 'http://localhost/cricruns-new/index.php/score-refresh/fetchdes/index/86/1',
success: function(html){
alert(html);
}
});
},delay);
});
</script>
it outputs the following
total:-370:-wickets:-4:-overs:-50.0:-striker:-Yusuf Pathan:-sruns:-8:-sballs:-10:-sfour:-0:-ssix:-0:-nonstriker:-Virat Kohli:-nsruns:-100:-nsballs:-83:-nsfours:-8:-nssix:-2
i want to split the result using :-
and i have to assign even values to the div which has the id as the odd value..
Upvotes: 17
Views: 163386
Reputation: 1105
Javascript String objects have a split function, doesn't really need to be jQuery specific
var str = "nice.test"
var strs = str.split(".")
strs would be
["nice", "test"]
I'd be tempted to use JSON in your example though. The php could return the JSON which could easily be parsed
success: function(data) {
var items = JSON.parse(data)
}
Upvotes: 29