jQuery issue here.

After calling some ajax, I'm having a problem getting a particular div to reload a php file. The only solution that I've come up with is to completely reload the page, but this is really undesirable, because this function is being used as part of a simple sort page.

So in the below code where it says location.reload() I would much prefer it to say something like $("#mydiv").load("phpfile.php"), so that it just loads the file into the div. This .load() actually does connect to the php file, but for some reason phpfile.php cannot finish the MySQL query it's trying to execute.


So the questions are:

1) Is there an easier way to do this than using .load()?

OR

2) If there isn't, why isn't the php file/MySQL query working properly?

function sorter(event){

	var order = $("#sortable").sortable('toArray');
	
	$.ajax({
	url: "sorter.php",
	async: false,
	data: {'id[]': order},
	complete: (function(data){
		location.reload();
		})
	})
}

Well, it looks like it was easier to run phpfile.php from sorter.php, and then put the data into #mydiv using $("#mydiv").html(data).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.