Unmatched end tag error

I can not find the “Unmatched end tag” Am I doing something else wrong which is causing a false error?

Any help would be appreciated.

$(function() {
  var points = [];

  var submit = function(points) {
  
    $.ajax(	{
		url: 'process.php',
		method: 'POST',
		data:	{
			points: points,
			name: '<?php echo $output ?>'
				},
		success :	{
			function(response){console.log(response)},
			function(htmlResponse){$('#ajaxResponse').html(htmlResponse)}
					}
			})
								}

  $("#test").click(function(e) {
    var offset = $(this).offset();
    points.push(Math.round(e.pageX - offset.left));
    points.push(Math.round(e.pageY - offset.top));
    if (points.length == 4) {
      submit(points);
      points = [];
    }
  });

});
1 Like

Should there be a ; at the end of this block?

2 Likes

Thanks @WebMachine that cleared the error.

EDIT: Woops I spoke to soon I still have the error! It seems to come and go in IE developers tools.

I am not getting it at all in Firefox developer tools.

1 Like

The code is malformed, so I’d expect errors in all browsers. Try this

$.ajax( {
  url: 'process.php',
  method: 'POST',
  data: {
    points: points,
    name: '<?php echo $output ?>'
  },
  success: function(htmlResponse){
    $('#ajaxResponse').html(htmlResponse)
  }
})

You’ll also need to be careful with $output to make sure it doesn’t contain single quotes otherwise it will be malformed, you’ll need to escape them \'

$.ajax( {
  data: {
    name: 'G\'day there'
  }
})

Thank you @markbrown4

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.