Reputation: 21617
I have the following jQuery and the file set-rank.php just updates a database and in the file it also writes the new data that I want to overwrite the #data section. my console log html response shows what I need it to but I can't get this to jquery to actually write my html response to my page.
JQUERY
$('input.ranking').keyup(function(e) {
var thisClass = $(this).attr('class');
var catID = $('input[name=catid]').val();
var substr = thisClass.split('-');
var pdID = substr[1];
var pdRank = $(this).val();
qString = 'pdID='+pdID+'&pdRank='+pdRank+'&catID='+catID;
//console.log(qString);
$.post('/assets/inc/set-rank.php', qString, function (data) {
console.log(data);
$('#data').html(data);
}, "json");
});
thanks in advance
Edit the console .log shows the following image. It wont write this html into my page
Upvotes: 1
Views: 2103
Reputation: 3586
Remove the last argument of $.post
aka the json
string. Since from what I see on your screenshot, the server returns HTML and not JSON data, so that causes it to fail.
Also: Instead of creating the string yourself you can pass an object into jquery's data
parameter as in {rank: pdRank, catId: id}
Upvotes: 2