Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to a member function finished() on null #57

Closed
vivekwaah opened this issue Apr 10, 2024 · 4 comments · Fixed by #58
Closed

Call to a member function finished() on null #57

vivekwaah opened this issue Apr 10, 2024 · 4 comments · Fixed by #58

Comments

@vivekwaah
Copy link
Contributor

vivekwaah commented Apr 10, 2024

Call to a member function finished() on null

If the URL has already query params, then it is getting error
Call to a member function finished() on null

On debugging found that the batchJobId is coming as the html content of the page.

Code snippet of problem

$.get(baseUrl + '?' + params.toString() + '&' + $.param(oTable.ajax.params())).then(function(exportId) {
    $wire.export(exportId)
}).catch(function(error) {
    $wire.exportFinished = true;
    $wire.exporting = false;
    $wire.exportFailed = true;
});

System details

  • Operating System - Ubuntu 22.04
  • PHP Version - 8.2
  • Laravel Version - ^10.10
  • Laravel-DataTables Version - ^10.1
@vivekwaah
Copy link
Contributor Author

I was able to fix the issue by changing $.get(baseUrl + '?' + params.toString() + '&' to $.get(baseUrl + '&' + params.toString() + '&'

@yajra
Copy link
Owner

yajra commented Apr 11, 2024

Your baseUrl may have a ? in it. We may need to enhance how the URL was built I guess.

@vivekwaah
Copy link
Contributor Author

vivekwaah commented Apr 11, 2024

Yes, the baseUrl may have the query params.

Can we use this to add the params

https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/set


var url = new URL('http://localhost:8000/reports');

var search_params = url.searchParams;
search_params.set('id', '101');
url.search = search_params.toString();
var new_url = url.toString();

console.log(new_url); // http://localhost:8000/reports?id=101
var url = new URL('http://localhost:8000/reports?user=2');

var search_params = url.searchParams;
search_params.set('id', '101');
url.search = search_params.toString();
var new_url = url.toString();

console.log(new_url); // http://localhost:8000/reports?user=2&id=101

@yajra
Copy link
Owner

yajra commented Apr 16, 2024

Yes, we could use that. Please feel free to submit a PR. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants